Controlling XFCE windows with wmctrl

Short guide explaining how you can use wmctrl to control windows, it’s useful if you want applications to automatically start on a specific desktop or screen.

The window list

$ wmctrl -l -x
0x048001dc  0 browser1:Navigator.browser1:Firefox-esr   N/A N/A
0x046001dc  0 browser2:Navigator.browser2:Firefox-esr   N/A N/A
0x04c001dc  0 browser3:Navigator.browser3:Firefox-esr   N/A N/A

The list of active windows, and the identifier of each window.

Move window to desktop

$ wmctrl -x -r :Navigator.browser1: -t 1

This will move the window “:Navigator.browser1:” to desktop 1

Move and resize window

$ wmctrl -x -r :Navigator.browser1: -e 0, -1, -1, 800, 600

This will keep the window in the same position and resize it to 800x600

$ wmctrl -x -r :Navigator.browser1: -e 0, 200, 200, -1, -1

This will keep the original size of the window and move it to location 200, 200

Changing window state (fullscreen, maximized, etc.)

$ wmctrl -x -r :Navigator.browser1: -b add,fullscreen

This will change the window to fullscreen

$ wmctrl -x -r :Navigator.browser1: -b remove,fullscreen

This will return the window to the original size

Moving maximized windows

$ wmctrl -x -r :Navigator.browser1: -b remove,maximized_vert,maximized_horz
$ wmctrl -x -r :Navigator.browser1: -e 0, 200, 200, -1, -1
$ wmctrl -x -r :Navigator.browser1: -b add,maximized_vert,maximized_horz

It’s not possible to move windows while they are maximized.

4 Likes

Just a heads up / warning, beware of accidentally moving the window for Xfdesktop (the wallpaper). The version of XFCE on Qubes 4.2 will not prevent you from doing this. You’ll know if it happens, you’ll see an alarming visual anomaly on the area of the screen no longer covered by the wallpaper. In my scripts for moving windows with wmctrl I check whether the window specified to be moved is Xfdesktop and bail out if so.

2 Likes