LinuxCommandLibrary

sxhkd

Bind keyboard hotkeys to commands

SYNOPSIS

sxhkd [-c CONFIG_FILE] [-m MONITOR_FIFO] [-s SIGNATURE_FILE] [-t] [-v]

PARAMETERS

-c CONFIG_FILE
    Specify an alternative configuration file path instead of the default.

-m MONITOR_FIFO
    Path to a FIFO (named pipe) where executed commands will be written, allowing for monitoring.

-s SIGNATURE_FILE
    Path to a file where sxhkd will write its process ID (PID), useful for scripting.

-t
    Test the specified configuration file for syntax errors and then exit. No commands are executed.

-v
    Print the version information of sxhkd and then exit.

DESCRIPTION

sxhkd (Simple X Hotkey Daemon) is a highly configurable and lightweight X hotkey daemon. Its primary function is to listen for keyboard and mouse events and execute commands defined in its configuration file. Designed for simplicity and efficiency, it integrates seamlessly with any X window manager, though it's particularly popular among users of tiling window managers like bspwm.

The configuration syntax is straightforward, allowing users to define single hotkeys or complex chorded keybindings (e.g., super + return ; super + alt + g). Upon startup, sxhkd reads its configuration, typically from ~/.config/sxhkd/sxhkdrc. It can reload its configuration file on the fly without needing to be restarted, making hotkey adjustments quick and easy. This daemon provides a powerful yet minimalist way to manage application launching, window manipulation, and system actions directly from keyboard shortcuts.

CAVEATS

Primarily designed for Xorg environments; it does not directly support Wayland. Hotkeys only work while the X server is running. Configuration file syntax must be followed precisely to avoid errors.

CONFIGURATION FILE (SXHKDRC)

sxhkd reads its hotkey definitions from a plain text configuration file, typically located at ~/.config/sxhkd/sxhkdrc. The file consists of sections defining a hotkey and the command(s) to be executed. Each hotkey definition starts with the hotkey itself, followed by the command(s) on subsequent indented lines.

Example hotkey definition:
super + Return
    urxvt

It supports various modifiers like super, alt, ctrl, shift, and specific keys. Chorded keybindings (chained presses) are also supported, separated by a semicolon (;). For example: super + p ; f could execute a command only after super+p is pressed, followed by f.

AUTOMATIC CONFIGURATION RELOAD

sxhkd can automatically reload its configuration file without needing to be restarted. This is typically achieved by defining a hotkey within sxhkdrc itself to send a SIGUSR1 signal to the sxhkd process, which triggers the reload. This allows for quick and seamless adjustments to keybindings without interrupting your workflow.

HISTORY

Developed by Bastian Germann, also known for the bspwm tiling window manager. sxhkd was created to provide a lightweight, flexible, and language-agnostic hotkey daemon that could complement bspwm but also function independently. Its design adheres to the Unix philosophy of doing one thing well, focusing solely on executing commands based on hotkey presses, and has gained significant popularity within the minimalist desktop environment community.

SEE ALSO

bspwm(1), xbindkeys(1), xmodmap(1)

Copied to clipboard