IT lexicon › Infra & Ops › wmctrl

wmctrl

Infra & Ops På svenska → Updated: 2026-10-09
More info
Creator
Tomáš Stýblo
Released
2003
Type
Command-line tool
License
GPL

The command-line tool that drives any EWMH-compliant window manager — list windows, activate one, maximise, switch desktop — by sending exactly the messages a pager would send.

Once EWMH had laid down how taskbars and pagers talk to the window manager, it became possible to write a program that does it from a script. Tomáš Stýblo released wmctrl in 2003; version 1.07 from 2005 was the last and is still the one distributions package, with a few patches. wmctrl -l lists every window with ID, desktop and title, -a "Firefox" activates and raises the first window that matches, -s 2 switches to the third desktop, -d lists the desktops with their work areas, and -r window -b add,maximized_vert,maximized_horz changes _NET_WM_STATE just as the window manager's own button would. -m reveals which window manager is running, read from _NET_SUPPORTING_WM_CHECK.

The tool never touches windows directly. Everything goes as ClientMessages to the root window, so the window manager keeps its policy; activations are sent with the source field set to "pager", which makes focus stealing prevention let them through as a user decision. That makes wmctrl the dull but dependable choice for scripts that arrange windows at login, while xdotool takes over where EWMH ends and XTEST is required. Under Wayland none of it works, since no client is allowed to see the others' windows, and every compositor has its own command instead.

← Back to the lexicon