sxhkdrc-mode for GNU Emacs

August 14, 2025 ยท View on GitHub

This is a major mode for editing sxhkdrc files. SXHKD is the Simple X Hot Key Daemon which is commonly used in minimalist desktop sessions on Xorg (I use it with bspwm, herbstluftwm, and i3wm). The sxhkdrc file configures key chords, binding them to commands. For the technicalities, read the manpage sxhkd(1).

Usage

Install the mode and use with any sxhkdrc file:

(use-package sxhkdrc-mode
  :ensure t
  :mode "sxhkdrc.*")

Restart the sxhkd daemon on demand with the command sxhkdrc-mode-restart. Or make it happen automatically each time you save a buffer that uses the sxhkdrc-mode by setting up the sxhkdrc-mode-auto-restart like this:

;; automatically reload the daemon after saving the file
(add-hook 'sxhkdrc-mode-hook #'sxhkdrc-mode-auto-restart)

Putting it all together:

(use-package sxhkdrc-mode
  :ensure t
  :mode "sxhkdrc.*" ; if you want more than just "sxhkdrc"
  :commands (sxhkdrc-mode-restart)
  :hook (sxhkdrc-mode . sxhkdrc-mode-auto-restart))