I'm trying to write a script that when called cycles through open X11 windows using wmctrl http://tripie.sweb.cz/utils/wmctrl/
Each time it is called it will cycle to the next window. I actually want to make two scripts one to cycle forwards and one to cycle backwards.
When I type "wmctrl -l" it lists the windows like this:
~]$ wmctrl -l
0x01000452 0 arch joe - File Manager
0x01800003 0 arch cycle-up
0x01c00020 0 arch BashScripts.org • Post a new topic
0x01a00020 0 arch wmctrl - A command line tool to interact with an EWMH/NetWM compatible X Window Manager.
0x01e00003 0 arch Terminal
The windows are listed in the same order each time I type "wmctrl -l".
And I can use "wmctrl -ai" to switch to a window; for example "wmctrl -ai 0x01000452" to focus and raise the File Manager window.
So I think I should be able to use wmctrl to cycle through windows.
But there's two main things I don't know how to do. Firstly the script will need to know which window is currently focused, (otherwize it couldn't know which window to cycle to next) and I don't know how to find this out. There seems to be an X11 command called "XGetInputFocus" but I can't work out how to use it. "man XGetInputFocus" doesn't help. Secondly I don't know how to parse the output of "wmctrl -l".
Note that when it gets to the end of the list of windows I want it to go back to the beginning of the list, so it can cycle endlessly.
This is what I have so far:
A = 'wmctrl -l'