wmctrl
Control and query window manager settings
TLDR
List all windows, managed by the window manager
Switch to the first window whose (partial) title matches
Move a window to the current workspace, raise it and give it focus
Switch to a workspace
Select a window and toggle fullscreen
Select a window and move it to a workspace
SYNOPSIS
wmctrl [options] [command] [arguments]
PARAMETERS
-m
Display information about the window manager.
-d
Display information about the desktops.
-l
List all managed windows.
-i
Interpret window and desktop IDs as decimal numbers instead of hexadecimal.
-r
Specify the target window.
-a
Activate the window specified by
-e
Move and resize the window specified by
-b
Manipulate window properties.
-c
Close the window specified by
-x
Print window class and machine name along with normal output.
-F
Force command execution even if window manager doesn't support EWMH.
DESCRIPTION
wmctrl is a command-line tool that allows you to interact with a running X Window System window manager. It provides a way to query information about windows, desktops, and the window manager itself, and also provides functionality to control these elements. This control includes operations like moving, resizing, activating, closing, and changing the state of windows.
It communicates with the window manager using the Extended Window Manager Hints (EWMH) and NetWM protocols, aiming to provide a consistent interface across different window managers that support these standards. This makes wmctrl a valuable tool for scripting and automating window management tasks. Using this tool is very useful for automation scripts where you can control the window placement and state of applications.
It's especially useful in environments where a graphical interface isn't readily available or where you need to perform window management operations programmatically.
CAVEATS
wmctrl's effectiveness depends on the window manager's adherence to EWMH and NetWM standards. Some window managers might not fully support these standards, leading to unpredictable behavior.
Window IDs are volatile and change upon window creation/destruction.
WINDOW IDENTIFICATION
wmctrl identifies windows using a combination of window ID, part of the window title, or the resource name of the application. When specifying a window by title, ensure the title is unique to avoid ambiguity. The '-x' option can assist in finding the correct window class name to use.
GRAVITY VALUES FOR -E OPTION
The gravity value in the '-e' option determines how the window's position is adjusted relative to its new size. Common values:
0: NorthWest
1: North
2: NorthEast
3: West
4: Center
5: East
6: SouthWest
7: South
8: SouthEast
9: Static