Linux: Xbindkeys Tutorial

By Xah Lee. Date: . Last updated: .

xbindkeys lets you set a keyboard shortcut to run a shell command, globally.

xbindkeys home page: http://www.nongnu.org/xbindkeys/xbindkeys.html

xbindkeys can bind almost any key or key combination. Example: Caps Lock, ScrLk, Pause, F2, number pad keys, multimedia keys, and special app launch buttons, and also standard modifier key combinations such as ▤ Menu, 【Ctrl+3】, 【Super+3】, etc.

Install

# Install xbindkeys
sudo apt-get install xbindkeys

There's also a GUI wrapper.

# install xbindkeys GUI
sudo apt-get install xbindkeys-config

Note: i haven't used the GUI tool. This tutorial is about command-line only.

Create the Config File

First, create a config file.

xbindkeys -d > ~/.xbindkeysrc

The xbindkeys -d will print out a default config sample file.

# sample xbindkeys config

# make F8 to launch or switch to Firefox
"firefox"
F8

Reload Config File

# reload xbindkeys config
killall -HUP xbindkeys

Actions

To fully use xbindkeys, you need to know what shell scripts to call.

Sending Keys

For example, have a shell command to send 【Ctrl+c】. See: Linux: Set F2 F3 F4 to Cut Copy Paste

Launching App

Use the app's command name directly. firefox, google-chrome, gnome-terminal, nautilus, ….

Call xdg-open to open file.

For GUI app command names or how to find the name, see:

Switch Windows

Linux: Add Keyboard Shortcut to Switch App

Control Sound

Linux: Change Volume by Command

Linux Keybinding Topic

  1. Linux: Keyboard Software Guide
  2. Linux: Swap Control Alt Keys, xmodmap
  3. Linux: Set F2 F3 F4 to Cut Copy Paste
  4. Linux: Swap CapsLock Escape Keys
  5. Linux: Make CapsLock Do Home Key
  6. Linux: Setup Shift Lock Key
  7. Linux: Add Keyboard Shortcut to Switch App
  8. Linux: Set Key Repeat Rate
  9. Linux: Set System Keyboard Layout
  10. Linux: How to Switch to Dvorak Keyboard Layout
  11. Linux: Change Volume by Command
  12. Linux: xmodmap Tutorial
  13. Linux: Xbindkeys Tutorial
  14. Linux: Find Keyboard Key Scancode
  15. Linux: X11 Keyboard Key Names