wmctrl – window control manager

2010-06-16 0 words 0 mins read

\"Blue
Image via Wikipedia

What is <a class="zem_slink freebase/en/wmctrl" title="Wmctrl" rel="wikipedia" href="http://en.wikipedia.org/wiki/Wmctrl">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 <a class="zem_slink freebase/en/window_manager" title="Window manager" rel="wikipedia" href="http://en.wikipedia.org/wiki/Window_manager">window manager for information, and it can request that certain window management actions be taken.

wmctrl is controlled entirely by its <a class="zem_slink freebase/en/command_line_interface" title="Command-line interface" rel="wikipedia" href="http://en.wikipedia.org/wiki/Command-line_interface">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 ’x’ (e.g. ’1280×1024’). The following two columns contain the fixed string VP: and then the viewport position in the format ’,’ (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:

<span style="color: #0000ff;">{12564}->[ up-10:34:2]-[ Pro-0191]wmctrl -d
0  * DG: <a class="zem_slink freebase/en/wsxgaplus" title="WSXGA+" rel="wikipedia" href="http://en.wikipedia.org/wiki/WSXGA%2B">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 <a class="zem_slink freebase/en/x_window_system" title="X Window System" rel="wikipedia" href="http://en.wikipedia.org/wiki/X_Window_System">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 <a class="zem_slink freebase/en/hexadecimal" title="Hexadecimal" rel="wikipedia" href="http://en.wikipedia.org/wiki/Hexadecimal">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 <a class="zem_slink freebase/en/client" title="Client (computing)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Client_%28computing%29">client machine name. The remainder of the line contains the window title (possibly with multiple spaces in the title).

Output sample:

<span style="color: #0000ff;">*{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:

<span style="color: #0000ff;">*{12564}->[ up-10:34:53]-[ Pro-0192]wmctrl -m
Name: Metacity
Class: N/A
PID: N/A
Window manager&#8217;s &#8221;showing the desktop&#8221; 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 ’<a class="zem_slink freebase/en/debian_gnu_linux" title="Debian" rel="homepage" href="http://www.debian.org/">Debian <a class="zem_slink freebase/en/bug_tracking_system" title="Bug tracking system" rel="wikipedia" href="http://en.wikipedia.org/wiki/Bug_tracking_system">bug tracking system – <a class="zem_slink freebase/en/mozilla" title="Mozilla" rel="wikipedia" href="http://en.wikipedia.org/wiki/Mozilla">Mozilla’

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 &#8221;Selected Window&#8221;

<span style="color: #ff6600;">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 &#8221;FIRE 001&#8221; | osd_cat -o 470 -s 8 -c red -d 10 -f -*-bitstream\ vera\ sans-*-*-*–250-*-*-*-*-*-*- ; sleep 1; wmctrl -o 0,0*<h6 class="zemanta-related-title">Related articles by Zemanta <ul class="zemanta-article-ul"> <li class="zemanta-article-ul-li"><a href="http://maketecheasier.com/kde-4-4-preview/2010/01/18">A Preview of KDE 4.4 (maketecheasier.com) <li class="zemanta-article-ul-li"><a href="http://blog.amit-agarwal.co.in/2010/01/16/whohas/">whohas (amit-agarwal.co.in) <li class="zemanta-article-ul-li"><a href="http://maketecheasier.com/run-multiple-x-sessions-without-virtualization/2009/07/11">How To Run Multiple X Sessions Without Virtualization (maketecheasier.com) <li class="zemanta-article-ul-li"><a href="http://www.xaprb.com/blog/2009/12/25/sanity-check-features-in-mysql/">Sanity-check features in MySQL (xaprb.com) <li class="zemanta-article-ul-li"><a href="http://blog.daryn.net/post/151824195/3-favorite-commands">3 favorite commands (daryn.net) <div class="zemanta-pixie"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/faf0be63-7089-42ae-9dbe-7b07f84a04e9/"><img class="zemanta-pixie-img" src="http://blog.amit-agarwal.co.in/wp-content/uploads/2010/08/reblog_b1.png" alt="Reblog this post [with Zemanta]" /><span class="zem-script more-related more-info pretty-attribution paragraph-reblog">


author

Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it