wmctrl – window control manager

Image via Wikipedia

What is wmctrl?

wmctrl  is  a  command that can be used to interact with an X Window manager that is compatible with the EWMH/NetWM specification.  wmctrl can query the window manager for information, and it can request that certain window management actions be taken.

wmctrl is controlled entirely by its command line arguments. The command line arguments are used to specify the action to be performed (with options that modify behavior) and any arguments that might be needed to perform the actions.

I have included some examples in the end.

Here are some of the interesting options and their descriptions:

-d     List  all desktops managed by the window manager. One line is output for each desktop, with the line broken up into space separated columns. The first column contains an integer desktop number. The second column contains a ’*’ character for the current desktop, otherwise it contains a ’-’ character. The next two columns contain the fixed string DG:  and then the desktop geometry as ’<width>x<height>’ (e.g. ’1280×1024’). The following two columns contain the fixed string VP: and then the viewport position in the format ’<y>,<y>’ (e.g. ’0,0’). The next three columns after this contains the fixed string WA: and then two columns with the workarea geometry as ’X,Y and WxH’ (e.g. ’0,0 1280×998’). The rest of the line contains the name of the desktop (possibly containing multiple spaces).

Output sample:

{12564}->[ up-10:34:2]-[ Pro-0191]wmctrl -d
0  * DG: 1680×1050 VP: 0,0  WA: 0,25 1680×1000  Workspace 1
1  – DG: 1680×1050  VP: N/A  WA: 0,25 1680×1000  Workspace 2

-l     List the windows being managed by the window manager. One line is output for each window, with the line broken up into space separated columns.  The first column always contains the window identity as a hexadecimal integer, and the second column always contains the desktop number (a -1 is used to identify a sticky window). If the -p option is  specified the  next  column  will  contain  the PID for the window as a decimal integer. If the -G option is specified then four integer columns will follow: x-offset, y-offset, width and height. The next column always contains the client machine name. The remainder of the line contains the window title (possibly with multiple spaces in the title).

Output sample:

*{12564}->[ up-10:34:8]-[ Pro-0191]wmctrl -l
0x01200003 -1 amit.themafia.info Top Panel
0x0120001f -1 amit.themafia.info Bottom Panel
0x01400011 -1 amit.themafia.info x-nautilus-desktop
0x07200004  0 amit.themafia.info aka

-m     Display information about the window manager and the environment.

Output sample:

*{12564}->[ up-10:34:53]-[ Pro-0192]wmctrl -m
Name: Metacity
Class: N/A
Window manager\’s \”showing the desktop\” mode: N/A

Some more EXAMPLES:
Getting a list of windows managed by the window manager

wmctrl -l

Getting a list of windows with PID and geometry information.

wmctrl -p -G -l

Going to the window with a name containing ’emacs’ in it

wmctrl -a emacs

Shade a window with a title that contains the word ’mozilla’

wmctrl -r mozilla -b add,shaded

Close a very specifically titled window sticky

wmctrl -F -c ’Debian bug tracking systemMozilla

Toggle the ’stickiness’ of a window with a specific window identity

wmctrl -i -r 0x0120002 -b add,sticky

Change the title of window to a specified string but choose the window by clicking on it
wmctrl -r :SELECT: -T \”Selected Window\”

These are taken from commadlinefu:

# rotate the compiz cube via command line
wmctrl -o 1280,0

# Auto Rotate Cube (compiz)
wmctrl -o 2560,0 ;sleep 2 ; echo \”FIRE 001\” | osd_cat -o 470 -s 8 -c red -d 10 -f -*-bitstream\\ vera\\ sans-*-*-*–250-*-*-*-*-*-*-* ; sleep 1; wmctrl -o 0,0


4 thoughts on “wmctrl – window control manager”