new xdotool version available (20090612)
Posted Sat, 13 Jun 2009
20090612: * Fixed bug where shift modifier was not reset when 'xdotool type' used. http://code.google.com/p/semicomplete/issues/detail?id=5
20090612: * Fixed bug where shift modifier was not reset when 'xdotool type' used. http://code.google.com/p/semicomplete/issues/detail?id=5
20090609: * Add '--delay' to xdotool type. Sets the delay between keys. * Add '--window ' to xdotool type, key, keyup, and keydown. This feature (key events with --window ) only works if the application does not reject X events that have 'send_event' set to true. Special notes: * Firefox appears to ignore all input when it does not have focus. * xterm ignores sendevent by default, ctrl+leftclick menu will let you enable it. * gnome-terminal appears to accept send_event input by default
The XEvent struct has a member 'send_event' which is true if the event came from an XSendEvent call and false otherwise. Programs like firefox and xterm (by default) ignore many events that have 'send_event' set to true.
Enter LD_PRELOAD.
Writing a custom shared library that overrides the default XNextEvent and XPeekEvent functions allows us to force 'send_event' to always be false, so an application with this library loaded will happily handle keyboard/mouse events generated with XSendEvent. I already have a helpful project that lets me write such a shared library: liboverride.
#include <stdio.h>
#include <X11/Xlib.h>
void hack_send_event(XEvent *ev) {
switch (ev->type) {
case KeyPress: case KeyRelease: case ButtonPress: case ButtonRelease:
ev->xany.send_event = False;
break;
}
}
override(`XNextEvent', `
{
real_func(display, event_return);
hack_send_event(event_return);
return;
}
')
This small bit of liboverride code will give me a shared library I can preload
with LD_PRELOAD. Doing so will ensure that send_event is false for any key or
mouse button events.
Works well. Now that we have a reliable way to allow XSendEvent I think it's worth putting this into xdotool.
20090126:
* Change the default behavior of 'getwindowfocus' to get the first
ancestor-or-self window that has WM_CLASS set. WM_CLASS will be set on
(all?) top-level windows and it's possible that the currently focused window
according to X is not a top-level window. To use the previous behavior, use
'getwindowfocus -f'
* Make 'xdotool key at' work correctly. 'at' is usually Shift+2, for example.
Now all shifted characters should work, but I've only tested on a US
keyboard.
* Minor Makefile fixes for package maintainers.
I've tested it in GNOME and Ion-3 with success.
Download: xdotool-20090126.tar.gz
# in .keynavrc f sh "activate-firefox.sh", endNow, in activate-firefox.sh:
#!/bin/sh # activate-firefox.sh xdotool windowactivate $(xdotool search -title -- '- Mozilla Firefox')
# in .keynavrc g sh "activate-gmail.sh"Now, in activate-gmail.sh:
#!/bin/sh # activate-gmail.sh ./activate-firefox.sh xdotool key ctrl+apostrophe xdotool type gmail xdotool key Return
20080606: * Correctly report an error if xdotool is invoked with an invalid command. * Fix invalid error code reporting from 'windowraise'
20080603:
* Daniel Kahn Gillmor reported a problem with return codes from xdotool. All
commands return proper exit status now (0 == success, nonzero == error)
* I tested on 3 window managers: Gnome2 2.20.0, OpenBox 3.4, ion-3rc-20070608
- Gnome2 and OpenBox pass all tests.
- ion-3 fails on any desktop-related methods (ion-3 lacks the support).
20080601:
* Add new commands:
- windowactivate: Activate a window. If the window is on another desktop, we
will switch to that desktop and then activate the window.
- set_num_desktops number: Changes the number of desktops or workspaces.
- get_num_desktops: Output the current number of desktops.
- set_desktop desktop_number: Change the current view to the specified
desktop.
- get_desktop: Output the current desktop in view.
- set_desktop_for_window window_id desktop_number: Move a window to a
different desktop.
- get_desktop_for_window window_id: Output the desktop currently containing
the given window.
windowactivate tested and confirmed working in: ion-3 and Gnome2 (metacity)
The rest of the new commands have only been tested in Gnome2. They do not
work in ion-3 due to lacking support for EWMH in ion.
* Rewrote the man page in perlpod format.
Tonight I added 7 new commands to xdotool (not yet in a release):
The last is window activation. It will jump you to the window and give it focus. If the window is on a different desktop, it jumps to that desktop and then activates the window. I've tested exactly that behavior (firefox lives on a separate desktop or workspace) in Gnome2 and ion-3, and it works.
Example: Jump to firefox:
./xdotool windowactivate $(./xdotool search -title "Mozilla Firefox")Example: Trying to do bad things in Gnome2
% ./xdotool set_num_desktops 5000 % ./xdotool get_num_desktops 36Example: Move firefox to another desktop
# Find firefox's X Window ID % MOZWIN=$(./xdotool search --title "Mozilla Firefox") # Find the desktop containing firefox. % ./xdotool get_desktop_for_window $MOZWIN 0 # How many desktops do we have? % ./xdotool get_num_desktops 5 # Move firefox to desktop 3 (index starts at 0) % ./xdotool set_desktop_for_window $MOZWIN 3 # Show me that firefox has moved to desktop 3 % ./xdotool get_desktop_for_window $MOZWIN 3 # Show me the current desktop % ./xdotool get_desktop 0 # Activate firefox's window (taking us to Firefox's desktop) % ./xdotool windowactivate $MOZWIN # Show that we're now on the same desktop as firefox % ./xdotool get_desktop 3I'll put out a new release after I have a chance to tidy up the code a bit.
20080521:
* Import patches from keynav's xdotool branch (From Lukas Mai) which make
xdotool compile happily when building with -Wall and -pedantic (and others)
* Finally convert to using Window type for (hopefully) everything instead of
incorrectly typecasting Window to int sometimes.
* Confirmed that the one (but mostly useless) test passes.