Once again I have started to use Ubuntu GNU/Linux to try to get away from Windows and explore more freedom respecting software. Of course there are going to be a lot of utilities you use in Windows that are not available in Linux so you have to find the equivalents. One of my must have utilities on Windows is AutoHotKey, especially since I use a TypeMatrix compact keyboard with a Dvorak layout. For example, my Z key is on the right side of the keyboard so I like to remap Ctrl + ; (semicolon) to activate Ctrl + z to undo things with my left hand.
The idea is that you use xbindkeys to listen for keyboard commands (input) and then you use xvkbd to type your desired keys (output).
Here is how to remap a combination of keys to another combination of keys on linux:
Install xbindkeys
sudo apt-get install xbindkeys
Create the default config file for xbindkeys
xbindkeys --defaults > /home/your-user-name/.xbindkeysrc
When thats done, install xbindkeys-config, the GUI for xbindkeys (note: the GUI is optional, you could just edit the config file with a text editor).
sudo apt-get install xbindkeys-config
Now the utility the actually does the “typing”
sudo apt-get install xvkbd
Once each is installed, start xbindkeys by bringing up “Run Application” with ALT -F2.
xbindkeys
If you want to launch the GUI editor you can run xbindkeys-config, but I found it to be more confusing than the text file.
Configuring your Shortcuts and Macros
Open your configuration file in your favorite text editor. It is called .xbindkeysrc in your home directory. Use the # character to comment out lines, such as the default macros placed by the program’s author — after I installed it, Ctrl + F was launching an xterm window all the time.
At the end of the file, put this:
"xvkbd -xsendevent -text "Cz"" control + semicolon
– r – Return
– t – Tab
– b – Backspace
– e – Escape
– d – Delete
– S – Shift (modify the next character)
– C – Control (modify the next character)
– A – Alt (modify the next character)
– M – Meta (modify the next character)
– [keysym] – the keysym keysym
Please note that modify with “S will be ignored in many cases. For example, “aCbScDCE will be
interpreted as a, Control-b, c, Shift-D, and Control-Shift-E.
"firefox" control + f
Now I just have to find an easy way to reload my xbindkeysrc config file when I make changes. Right now I’m killing the process and launching it again.
Final note: you can set xbindkeys to launch on startup — in ubuntu, just go to System -> Preferences -> Startup Applications and add a new command xbindkeys.
First of all, thank you for pointing me in the right direction. I’m also making the move to Ubuntu from Windows, and I was an extremely heavy user of AutoHotKey.
The xbindkeys program, along with its companion xbindkeys-config, was exactly what I was looking for. Personally, I found xdotool easier to use as the program for typing in the virtual keystrokes, and it allowed me to activate specific windows as well.
Unfortunately, all my keymappings are now global whereas in AutoHotKey they were declared per-program, but for now this is the best replacement I’ve found so far. I tried AutoKey for about a day and found it to be very buggy in Ubuntu 11.04.
Yes I think AutoHotKey for windows is absolutely amazing and I thought it was odd that there isn’t anything really like it on Ubuntu. But maybe that’s because you can do so much just from the command line, which leads to writing your own scripts (i.e. python or perl)
Have you found a way to set per application hot keys?
Thank you very much indeed for this tutorial.
But I have got a question. I wanted to remap my shutdown / sleep mode keys so that they could work as they are, because the system doesn’t react at all while I push on them.
I’ve made the file using “sudo xbindkeys-config” and this is what I’ve got:
#Shutdown
“shutdown -h 0″
m:0x0 + c:124
XF86PowerOff
#Hibernate
“hibernate”
m:0x0 + c:150
XF86Sleep
But still, when I press “Run Action” in XBindKeys Config everything is okay. My Ubuntu hibernates and shuts down. And if I just press these buttons, they don’t work. I guess I need to have “root” access here or what’s wrong?
After you modify the xbindkeys script, for the new bindings to take effect you have to restart xbindkeys like this: killall xbindkeys && xbindkeys (which exits xbindkeys and starts it again). Enter that at a console. If it still doesn’t work, another program such as X11 might be “taking over” those keys so xbindkeys cannot access them. You could also try running your distribution’s Keyboard shortcut modifier program to run a custom command.
I am another Windows escapee who has come to rely on AutoHotKey.
I also found Xbindkeys-config absolutely unintelligible – why couldn’t it just have two fields, one where you press the hotkey you want, and the other either put a command or “text” ?
The string method doesn’t work for me, the simple launch of Firefox does.
>Now I just have to find an easy way to reload my xbindkeysrc config file when I make changes. Right now I’m killing the process and launching it again.
Obviously xbindkeys-config ought to have a Reload Script button, just like AutoHotKey does. Is that what the Load button does ? Apparently not.
There’s gotta be a better way.
I also rely on AutoHotKey. Were you ever able to find a better way to set this stuff up?
The better way: AutoKey(GTK)
Working straight away.
Works great! Thank you for your HOW-TO
tl;dr: install AutoKey for Linux (in Mint, prolly many others)
how about xmodmap
How do you change another key to Home and End key? They’re not on the list, so is that not possible? My wireless keyboard is super annoying in that you need to hold down a Fn key to get access to Home and End keys
Thanks. This is what I need
Version 1.8.3 : A listen loop was added in the main loop. This fix a bug where, in the previous version, a keypress was needed to reload the configuration file after a keybinding change. Now one can edit the configuration file and keybindings are automatically updated after each save. Many thanks to Edwin Stang!
This should mean that there is no need to restart xbindkeys after each change. I did have to restart the whole machine/display manager once after I first enabled xbindkeys because Gnome wasn’t letting xbindkeys access certain shortcuts.