wmctrl, a handy tool for you to manipulate windows

December 13th, 2006 mysurface Posted in fluxbox, wmctrl, X11, zenity | Hits: 47856 | 7 Comments »

Every piece of GUI programs is frame in a windows, windows have various behavior, either shading, sticky, minimized, maximized, icontify, active, inactive or open at different workspace, and properties such as windows size, title etc. With wmctrl, we can manipulate our windows and do something useful or fun trick.

A friend of mine throw me a question. “Can I open a gnome terminal at specific workspace?” gnome-terminal itself can’t perform that art, its quite upset sometimes, compare to konsole, konsole do more. Again I am not sure whether konsole support open at specific workspace.

With help of this handy tool, yes you can open gnome-terminal at specified workspace.

gnome-terminal -t mytitle; wmctrl -r mytitle -t 3

-t at gnome-terminal is to set a title for itself, and -r at wmctrl side, is to target a window for an action, -t is to move to workspace, here 3 it moves to 4th workspace. (workspace ID start from 0)

To list all the windows, do this

wmctrl -l

It shows you all the windows (ID and title) and its location. The output looks like

0x01c0005d  0 zion Linux by Examples › Create New Post — WordPress - Firefox
0x00800003 -1 zion gkrellm
0x03000003  0 zion Volume Control: Intel 82801DB-ICH4 (Alsa mixer)
0x02e0000c  0 zion Skypeâ„¢ - mysurface
0x01800228  1 zion XChat: surface @ FreeNode / #ubuntu-my (+n)

As you can see, I am opening gkrellm with sticky (-1), appears every workspace, skype, volume control at workspace 0 and xchat at workspace 1.

To move a windows based on its ID instead of title, specified with -i.

wmctrl -i -r 0x03000003 -t 2

You can add, remove or toggle the behavior of windows, such as shaded, bellow example will shade the current active windows.

wmctrl -r :ACTIVE: -b toggle,shaded

With this, you can bind to your key in fluxbox or other X windows manager that support key binding.

You can even change the title of specific windows

wmctrl -r :SELECT: -T "my sample title"

With :SELECT:, your mouse cursor will change to allow you to select any windows.

Having fun? I do, I hope you do too.

Final, I grab this at here.

title=`zenity --entry --title "Change window title" \
    --text "New window title"`; \
    wmctrl -r :SELECT: -T "$title"

With help of zenity, changing title for windows become very convenient.

7 Responses to “wmctrl, a handy tool for you to manipulate windows”

  1. Nice tool! I always wish to manipulate windows through cli

  2. I wish I bumped into your post before. It took me a while to figure out wmctrl. But I did, and I wrote up some examples here:


  3. That is Great! Sy All, thanks for sharing :)

  4. [...] For those who are using older version of Fluxbox, you can make use of wmctrl. [...]

  5. [...] For those who are using older version of Fluxbox, you can make use of wmctrl. [...]

  6. Nice example, Thanks

  7. I was looking for this for a long time! Didn’t know that resizing the :ACTIVE: window was so easy. I use AutoKey to execute the commands, very handy!

Leave a Reply