You need the following components to run Xhotkeys:
- X-Window System (XFree86 or Xorg)
- Python 2.3
- Python-Xlib 0.12
- Python-GTK 2.4
You have to configure your destkop environment to run Xhotkeys at startup. For example, with GNOME you will do:
- System-> Preferences -> Sessions
- StartUp Programs -> Add
- StartUp Command: xhotkeys (order: 50)
And restart the session. Then open the graphical configurator running xhotkeys --config:
Here you can add new entries, delete them or edit the existing ones. Configuration will be saved on exit. On Edit hotkey window you must fill the name and command entries (hotkey may remain disabled). While you are recording a key you can abort pressing Esc. To disable the hotkey for the entry, just press BackSpace.
You can also use mouse buttons. You will see that these special keys are recorded as Button1, Button2, Button3., and so on..
Names and hotkeys entries cannot be repeated. Commands are run though the default shell (normally, bash), which is useful for many reasons:
Xhotkeys uses a configuration file for each user which is saved at $HOME/.xhotkeys. If you open it with a text editor, you'll see that it's simple to modify manually.
For those who were used to Microsoft Windows, probably they they miss nice applications as Babylon (I did!): you know, simply pressing a Control + mouse button you got the definition (or translation) of the word where the cursor was, no need to select it. Wonderful, but in GNU/Linux we can put several apps to work collaborative, and achieve similar or better results.
If you want something similator to Babylon, just install xsel and xautomation debian packages, write a bash script like this (on /usr/local/bin):
#!/bin/bash # getdclick: simulates double-clic and get selected word # Time to wait between clicks (test what works for you) DCLICK_WAIT=0.1 # Before double-click, simulate a Release of all buttons xte "mouseup 1" "mouseup 2" "mouseup 3" "mouseup 4" "mouseup 5" # Now simulate double click xte "mouseclick 1" "sleep $DCLICK_WAIT" "mouseclick 1" # Get selection first word from primary X clipbloard SEL="$(xsel -p | awk '{print $1}')" if [ "$SEL" = "" ]; then exit 0; fi # Substitute @SEL@ by the selected string EXEC=$(echo $* | sed "s/@SEL@/$SEL/g") exec $EXEC
And then configure xhotkeys to launch it however you want:
#.xhotkeys: xhotkeys configuration file definition=<control>Button3:getdclick gnome-dictionary @SEL@ translate=<control><shift>Button3:getdclick dillo "www.wordreference.com/es/translation.asp?tranword=@SEL@"
Great! isn't it?