Outdated documentation

This page is out of date. Please use the main navigation to find the latest documentation.

For users who wish to have smart keyboard or mouse shortcuts to open applications, run commands or insert a certain combination of keystrokes, move the mouse, etc. (macros), this guide may come in handy.


If you don't need to run macros, installing xbindkeys will be sufficient.

 $ sudo apt-get install xbindkeys

If you want to run macros, you should install xmacro as well. (xmacro is able to press keys, mouse buttons and move the mouse.)

 $ sudo apt-get install xmacro

Configuring xbindkeys

Create a file called .xbindkeysrc in your home folder.

 $ touch ~/.xbindkeysrc

Open the newly created file in your favourite text editor and add the following:


Now, for the sake of testing if it works, replace those two lines with the following:

 "icecat &"
 Shift + F5

Save the file and run the following in a terminal:

 $ xbindkeys

Now, when you press Shift and F5, icecat will be launched.

Next, let's try and add another command. Edit the .xbindkeysrc file and append the following lines:

 "gedit &"
 Shift + F6

Save the file, and run xbindkeys again.

 $ xbindkeys

Now, gedit will be opened when Shift and F6 are pressed.

NOTE: Some keys and keycombinations may be predefined by the window manager, and will overwrite your keybinds. If your keybind doesn't work, try another keycombination to make sure that it is not caused by the window manager.

NOTE: You need to start xbindkeys everytime the system starts, in order for your binds to work.

Using the mouse

You can also use mouse buttons for keyboard shortcuts. Let's try and replace F6 with b:2 (this is the middle-button on most mice. If your mouse doesn't have a middle button, try b:1 for LMB or b:3 for RMB). Run xbindkeys again and when you hold Shift and press your middle mouse button, gedit should be opened.

If you have a mouse with a lot of buttons, you can define their behaviour this way.

Combining xbindkeys and xmacro

If you want a certain key or combination to yield another combination, you need to use xmacro. In this example, we will make Shift + Mouse scroll (up/down) press the left and right arrow keys. This can be useful when selecting text using the mouse.

Open your .xbindkeysrc file and add the following lines:

 "echo -e 'KeyStrPress Left\n KeyStrRelease Left' | xmacroplay ':0.0'"
 Shift + b:4

 "echo -e 'KeyStrPress Right\n KeyStrRelease Right' | xmacroplay ':0.0'"
 Shift + b:5

Getting xmacro events

Writing macros can be difficult, if you don't know the names of the keys you want to press. In short, there are 13 different events, that xmacro can run:

If you don't know the name of the event you wish to use, you can use xmacrorec2, which will output the events that you press to a terminal. Alternatively, you can make xmacrorec2 record the events to a file, which can then later be run.

 $ xmacrorec2 > my.macro
 >> Record macro...
 $ cat my.macro | xmacroplay ":0.0"

Useful examples

There are several ways using xbindkeys and xmacro, to create neat and useful shortcuts. If you use a shortcut that you think might be useful to other users, please add it below.

Open top by holding shift down and clicking first with LMB, then with RMB.

 "gnome-terminal --hide-menubar --title=top --geometry=80x45-2-27 -x top &"
 Shift + b:1 then Shift + b:3


Documentation/CustomKeyboardShortcuts (last edited 2013-08-29 19:05:50 by FelipeLopez)