from man wmctrl:
wmctrl is a command that can be used to interact with an X Window manager that is compatible with the EWMH/NetWM specification. wmctrl can query the window manager for information, and it can request that certain window management actions be taken.
The question specifically
The wmctrl -d
command can be used to get information about desktops (viewports/workspaces), The wmctrl -lG
command lists all windows, including their geometry information.
How can I (in Unity versus other window managers):
- get an overview of the workspaces and how they are arranged?
- find out which is the current workspace?
- find out where a window is located in an absolute sense?
- list windows that are on the current workspace?
from the command line, using these two commands?
Background information
The wmctrl -d command
lists desktops. On (e.g.) Xubuntu, when I run wmctrl -d
, I can clearly see in the output which is the current workspace, and the screen's resolution (DG) on the workspace(s).
0 - DG: 1024x600 VP: N/A WA: 0,31 1024x569 1
1 - DG: 1024x600 VP: N/A WA: 0,31 1024x569 2
2 - DG: 1024x600 VP: N/A WA: 0,31 1024x569 3
3 * DG: 1024x600 VP: 0,0 WA: 0,31 1024x569 4
The current workspace is marked with a *
.
On Unity however, the output of wmctrl -d
shows only one (very large) workspace, marked with a *
, no matter which is the current "workspace", e.g.:
0 * DG: 3360x2100 VP: 1680,0 WA: 65,24 1615x1026 N/A
The wmctrl -lG command
from man wmctrl
:
-l
: List the windows being managed by the window manager.
-G-
: Include geometry information in the output of the -l action
When I run wmctrl -lG
on (e.g.) Xubuntu, with a mousepad window on each workspace:
0x03400003 0 241 197 533 244 jacob-1001PX Untitled 1 - Mousepad
0x03400197 1 299 222 533 244 jacob-1001PX Untitled 2 - Mousepad
0x034001be 2 236 201 533 244 jacob-1001PX Untitled 3 - Mousepad
0x034001e3 3 283 228 533 244 jacob-1001PX Untitled 4 - Mousepad
The information is quite understandable; from the second column, we know the workspace the window is on, its position (x,y, column 3/4) and the size (x,y, column 5/6). The position is given in relation to the worspace it is located on.
On Unity however, it is quite a different story. When I have four workspaces and I open a gedit window on every one of them:
0x03c03b81 0 468 -884 875 741 jacob-System-Product-Name Niet-opgeslagen document 1 - gedit
0x03c03e74 0 369 164 1111 741 jacob-System-Product-Name Niet-opgeslagen document 2 - gedit
0x03c03f8e 0 -1269 214 1111 741 jacob-System-Product-Name Niet-opgeslagen document 3 - gedit
0x03c00085 0 -1376 -917 1111 741 jacob-System-Product-Name Niet-opgeslagen document 4 - gedit
Some windows have negative coordinates, some (may) have coordintates that exceed my screen's resolution.