Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the alternatives to wmctrl?

Tags:

linux

x11

Do you know of any alternatives to wmctrl? A program that lets you manipulate windows and window management from the command line.

One drawback with wmctrl is that whilst you can manipulate the current window, you cannot get wmctrl to list information about the current window (it ignores -r).

like image 606
joeytwiddle Avatar asked Nov 24 '10 22:11

joeytwiddle


1 Answers

To find the id of the currently active window, use:

xprop -root -f _NET_ACTIVE_WINDOW 0x " \$0\\n" _NET_ACTIVE_WINDOW | awk "{print \$2}"

Using this id, you can then get a lot of information about the currently active window:

xprop -id $(xprop -root -f _NET_ACTIVE_WINDOW 0x " \$0\\n" _NET_ACTIVE_WINDOW | awk "{print \$2}")

From there, you can grep what you need, or make it show just the desired field the same way I extracted _NET_ACTIVE_WINDOW above. So, to find the PID of the currently active window, you would append -f _NET_WM_PID 0c " \$0\\n" _NET_WM_PID to the command above, making it:

xprop -id $(xprop -root -f _NET_ACTIVE_WINDOW 0x " \$0\\n" _NET_ACTIVE_WINDOW | awk "{print \$2}") -f _NET_WM_PID 0c " \$0\\n" _NET_WM_PID | awk "{print \$2}"

Note that wmctrl also accepts the same kind of id in combination with the -i flag.

like image 91
Amir Avatar answered Oct 14 '22 15:10

Amir