DBA Corner

Data is stored somewhere

xbindkeys: Create Safe Linux Keyboard Shortcuts

xbindkeys runs commands from keyboard or mouse shortcuts under the X Window System. It is useful for lightweight X11 desktops, but many Wayland sessions restrict global key capture; in that case, use the desktop environment’s native shortcut settings.

Capture a key combination

xbindkeys --key

Press the desired key once. For combinations that are difficult to capture, use:

xbindkeys --multikey

Copy the symbolic result, such as Mod4 + F5, rather than relying only on a machine-specific numeric keycode.

Add a binding

Edit ~/.xbindkeysrc and add a command followed by its shortcut:

"/home/alex/bin/backup-status"
  Mod4 + F5

Use an absolute command path. Make the script executable, run it once from a terminal, and confirm that it works without an interactive prompt.

Start and verify

xbindkeys --show
xbindkeys --verbose

If an older xbindkeys process is already running, use your desktop session’s normal restart or autostart mechanism after changing the file. Avoid starting multiple copies.

Security and reliability

  • Do not bind a shortcut to a command that requires a stored administrator password.
  • Quote paths and arguments carefully, and keep writable scripts out of shared directories.
  • Test what happens when the command is launched repeatedly.
  • Prefer a small wrapper script for multi-step actions so it can log errors and use a predictable environment.
  • Check for conflicts with window-manager and desktop shortcuts.

The Super or Windows-logo key is normally reported as Mod4 on X11, but the exact mapping can vary. Capture the combination on the target machine instead of copying raw keycodes from another system.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *