xdo updates: window operations and searching
Posted Fri, 22 Jun 2007
% ./xdotool search "Mozilla Firefox" 31457484 % xwininfo -id 31457484 | egrep 'Width|Height' | paste - - Width: 1278 Height: 1008 % ./xdotool windowsize `./xdotool search "Mozilla Firefox"` 500 500 % xwininfo -id 31457484 | egrep 'Width|Height' | paste - - Width: 500 Height: 500This new 'search' command will walk the list of windows in X and basically output any windows with a matching title, name, or class. In this case, I have 1 "browser" window open under firefox that has "Mozilla Firefox" in the title. So I then resize it to 500x500, trivially.
Longer summary of today is that I added 4 new functions to xdotool:
- windowsize <windowid> <width> <height>
- windowfocus <windowid>
- windowmove <windowid> <x> <y>
- search <regexp>
Turns out XTEST works as I'd expect, and this example will do what you think, and switch to the 2nd console (assuming you're running one).
% ./xdotool key "ctrl+alt+F2"
Goal: Focus the first window found that is a local xterm (ie; not ssh'd anywhere). My xterms have title with 'host(pwd) - activity' in them. So if my local host is 'snack' I can do:
# Look for xterms starting with 'snack(' and focus the first one ./xdotool search '^snack\(' | head -1 | xargs ./xdotool windowfocusAnd magically one of the xterms running a shell locally is focused. I can see this being pretty useful.
Today's code: navmacro-20070622.tar.gz.