Linux · Accessories
wmctrl
wmctrl is a command‑line tool to interact with an X11 window manager, allowing you to list, move, resize, and close windows.
- License
- GPL-2.0
- Latest version
- 1.07
What is wmctrl?
wmctrl has been around for many years in the X11 ecosystem and is packaged in the major distros (Arch, Debian, Fedora, openSUSE, Ubuntu). It talks to the window manager via the EWMH/NetWM protocol, so it works with most modern desktop environments. Its simplicity and scriptability make it a go‑to utility for power users who need to automate window handling.
The tool is aimed at users comfortable with the terminal and shell scripting—people who want to tweak their workflow without a graphical interface. It is often used in custom scripts, tiling‑window‑manager setups, or to replace ad‑hoc Windows tools like PowerToys' FancyZones for window placement.
Compared with PowerToys, wmctrl feels more low‑level and less polished; there is no GUI, and you must know the command syntax. However, it is lightweight, works on any X11 session, and can be combined with other CLI tools for very precise control.
Best for: Scripting‑savvy users who need precise, repeatable window control on X11 desktops.
Key features of wmctrl
- List all open windows with IDs and titles
- Move, resize, and raise/lower windows
- Change window state (maximized, minimized, fullscreen)
- Close windows by ID or name
- Set desktop/workspace for a window
- Activate (focus) a specific window
- Works with any EWMH‑compliant window manager
Pros
- Small, no dependencies beyond X11
- Works across most Linux desktop environments
- Ideal for scripting and automation
- Available in all major distro repos
Cons
- Only works on X11, not Wayland
- No graphical interface; steep learning curve for newcomers
- Limited to window management; does not replace other PowerToys features
Windows programs wmctrl replaces
How to install wmctrl on Linux
sudo apt install wmctrlsudo apt install wmctrlsudo dnf install wmctrlsudo pacman -S wmctrlsudo zypper install wmctrlTips for Windows users
PowerToys' FancyZones relies on a visual editor; with wmctrl you’ll script window placement using window IDs or titles. Learn the basic commands (wmctrl -l, wmctrl -r <WIN> -e <geom>) and map your favorite shortcuts (e.g., bind Super+Enter to a script that moves the focused window). No file formats need conversion, but expect to shift from drag‑and‑drop layout design to text‑based scripts.
wmctrl: frequently asked questions
How do I list all windows with wmctrl?
Run wmctrl -l; it prints each window's ID, desktop number, and title.
Can wmctrl move a window to a specific workspace?
Yes, use wmctrl -r <WIN> -t <DESK> where <WIN> is the window ID or title and <DESK> is the workspace number.
Is wmctrl usable under Wayland?
No, wmctrl works only with X11; under Wayland you need tools like swaymsg for Sway or kwin-wayland scripting.
How can I bind a key to maximize a window with wmctrl?
Create a small script calling wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz and bind it in your desktop's keyboard settings.
Updated