Skip to content
Advertisement

Programmatically hide/show a window in Linux

I’ve been searching all over the place for a solution to this.

How can I show/hide (or minimize/unminimize if you rather) Linux windows.

I’m interested in any solution in any language.

I use Debian, Gnome, Metacity and Compton composite manager if they’re relevant

Note: I tried using wmctrl but the toggle,hidden feature of wmctrl has been broken for a while and it’s not been updated in two years so unlikely to work any time soon. The net is full of bug reports concerning this.

Advertisement

Answer

You can use xdotool:

$ xdotool search --name "Stack Overflo"
24415619
$ xdotool windowminimize 24415619

Basically, you first find a window (by title, by active state etc.), which gives you its ID. Then you invoke commands. There are many ways to find a window, see the manpage.

xdotool is available as a package in at lease Debian, Ubuntu and Fedora.

Note: Shamelessly stolen from this answer: https://superuser.com/questions/186748/how-to-hide-or-minimize-x11-window-from-console

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement