You need the following components to run Xhotkeys:
- X-Window System (XFree86 or Xorg)
- Python 2.3
- Python-Xlib 0.12
- Python-GTK2.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)
You will have to 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 the 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), this means many useful things: you don't need to give the complete path (it uses the default environment), it's possible to pass arguments with it, and command expansion (`` or $()) is allowed.
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. To start, we could do simple but very useful things like opening our favourite X terminal:
#.xhotkeys: xhotkeys configuration file terminal=<alt><control>Enter:gnome-terminal
For those who were used to Microsoft Windows, probably they miss nice applications as Babylon (I did!): simply pressing a Control + mouse button you got the definition (or translation) of the word where the cursor was, no need to select it.
Right, but in GNU/Linux we can achieve similar results using not one but many utilities. Just create a little bash script like this (you'll need xsel and xautomation debian packages):
#!/bin/bash # doubleclicksel: Get Double Click Selection and run an external application with it # Time to wait between clicks (desktop-dependant, test what works for you) DCLICK_WAIT=0.1 # Simulate double click xte "mouseclick 1" "sleep $DCLICK_WAIT" "mouseclick 1" # Get selection from primary X clipbloard SELECTION="$(xsel -p)" # Substitute @SEL@ by the selected string EXEC=$(echo $* | sed "s/@SEL@/$SELECTION/g") echo "launching... $EXEC" $EXEC exit $?
And then configure some key launchers that use it:
#.xhotkeys: xhotkeys configuration file definition=<control>Button3:doubleclicksel gnome-dictionary @SEL@ translate=<control><shift>Button3:doubleclicksel dillo "www.wordreference.com/es/translation.asp?tranword=@SEL@"
Great! isn't it?