Custom key bindings in Linux

22 June 2013

There are various ways to create custom key bindings/mappings in Linux. This tutorial uses xbindkeys on Ubuntu.

xbindkeys is a program that allows you to launch shell commands with your keyboard or mouse under the X Window System. It links commands to keys or mouse buttons, using a configuration file.

I have a ThinkPad and my keyboard has one of those blue buttons. Might as well put it to good use. I take a lot of screenshots, I’ll use it for that.

  1. Install xbindkeys
    apt-get install xbindkeys

  2. Create a configuration file for xbindkeys
    touch $HOME/.xbindkeysrc

  3. Identify the key to be used for launching the command
    xbindkeys --key

    
    Press combination of keys or/and click under the window.
    You can use one of the two lines after "NoCommand"
    in $HOME/.xbindkeysrc to bind a key.
    "NoCommand"
        m:0x10 + c:156
        Mod2 + XF86Launch1
    
  4. Add the following key binding to the configuration file $HOME/.xbindkeysrc

    
    "gnome-screenshot"
      m:0x10 + c:156
    

    or

    
    "gnome-screenshot --window --remove-border --effect=shadow"
      Mod2 + XF86Launch1
    
  5. Autostart xbindkeys (without arguments) on login. One option is to use the “Startup Applications” tool.

This content is open source.
Please help improve it.