Controlling XFCE windows with wmctrl

Original forum link
https://forum.qubes-os.org/t/22299
Original poster
renehoj
Created at
2023-11-26 18:59:24
Posts count
2
Likes count
6
Tags
xfce

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.