New keynav release available
Posted Wed, 27 Jun 2007
View the project page and/or download keynav-20070629.tar.gz
Update: 20070627 had problems with $HOME so I released a new version (0629).
View the project page and/or download keynav-20070629.tar.gz
Update: 20070627 had problems with $HOME so I released a new version (0629).
% ./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:
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 windowfocus
And 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.
The result so far is as follows:
So right now, I can do this:
Interested in the code? Download navmacro-20070620.tar.gz.
Note: navmacro works on my ubuntu and freebsd systems just fine. However, xdotool crashes at the end when I do free(xdo->charcodes) only on my Ubuntu system. Uncertain why, I'm way too tired to debug.
The primary example I used was focusing firefox's URL bar without the mouse. The sequence was this: Switch to Desktop 2 (I press Alt+2), focus firefox's URL bar (using control+l) and clear it.
The result is a simple tool I'm tentatively calling 'xdo'. You can download the source here. Compile instructions are at the top of the file.
The top of xdo.c details the implemented commands, so let's cut to an example:
% echo 'key alt+2; sleep 1; key ctrl+l; key BackSpace' | ./xdoIt does exactly what you think. The 'sleep' command has values in milliseconds, and is only necessary to slow down so that events can propgate fast enough (window focus changes, etc).
Another reasonable example would be to say "firefox, open a new tab and load the URL in my clipboard":
# My clipboard contains a valid url, say, "http://www.google.com/" (echo "key alt+2; sleep 1; key ctrl+l; key BackSpace;" echo "move 55 55; sleep 1; click 2; key Return") | ./xdoSeems complex, but look at what's really happening: Go to desktop 2, focus urlbar, hit backspace (clearing it), move the mouse cursor to 55,55 (a point inside the urlbar for me), hit middle mouse button to paste.
Change "ctrl+l" to ctrl+k (unix firefox) to focus the "Search" box instead, and change the 'move' command to cursor over the search box to paste instead, and suddenly you can bind a simple keystroke to search for whatever is in your X clipboard. Useful.
One of the neater features is that you can 'type' text:
% echo 'type echo hello there; key Return' | ./xdo echo hello there % echo hello there hello there