Intro to skhd
I learned about skhd recently, actually after coming across the yabai project.
I’ve been toying with the idea of moving away from Hammerspoon for my hotkey and window management, so I took the opportunity to explore skhd as a possible alternative.
Initial setup
To get started on macOS, I followed the guide in the project README.
First, I installed skhd via brew.
brew install koekeishiya/formulae/skhdThe instructions say to start the service immediately with
skhd --start-serviceI think it makes more sense to first write a skhdrc config file and validate your syntax is good.
I created my config file at ~/.config/skhd/skhdrc with the following initial contents:
shift + cmd - j : echo 'hello SKHD'I validated my config file by running in verbose mode
skhd --verbosewhich output
skhd: successfully created pid-file..skhd: using config '/Users/danielcorin/.config/skhd/skhdrc'hotkey :: #1 { mod: 'shift' mod: 'cmd' key: 'j' (0x26) cmd: 'echo 'hello SKHD''}skhd: watching files for changes: /Users/danielcorin/.config/skhd/skhdrcI didn’t get any output to the console or log file from my command when running in verbose mode.
After confirming the configuration was valid, I started skhd with
skhd --start-servicethen tailed the logs to validate the effects of my hotkey
tail -f /tmp/skhd_$USER.out.logPressing ⌘ Command + ⇧ Shift + J, I validated that hello SKHD showed up in the log file.
Doing something useful
With skhd, we can bind arbitrary shell commands to hotkeys.
The following creates a daily post entry in my blog, using a script in the repo:
shift + cmd - j : cd /Users/danielcorin/dev/hugo/blog && make logThis hotkey runs Python code via make from my blog directory’s script folder to create a file then opens the file as well.
The hotkey improves my workflow from running make log in my blog’s project directory to running ⌘ + ⇧ + J anywhere.
Takeaways
skhd is a nice hotkey management tool but feels a bit raw.
It would be nice if there were some additional quality of life features to help as you work through the learning curve of the tool, like hotkey collision detection and logging in verbose model.
Once you get used to it though, it’s quite powerful and simple.
It pushes you move the complexity of your action out of skhdrc and into scripts that it can invoke.
I prefer this separation-of-concerns approach to my current Hammerspoon config, which has the hotkey bindings and action logic all together, though splitting this up would be straightforward.
I’m not completely sold yet, but skhd remains a candidate to adopt into my workflow.
If I can figure out a nice solution for toggle apps, I might make the switch.
Recommended
Mapping Caps Lock to a Hyper Key with Karabiner and Goku
Karabiner is a keyboard customizer for macOS. I've used it for a while to map my caps lock key to <kbd>cmd</kbd> + <kbd>ctrl</kbd> +...
Using My Full Keyboard as an App Launcher with Goku Simultaneous Layers (Simlayer)
Goku has a concept called a simlayer. A simlayer allows you to press any single key on the keyboard, then any second key while holding the first and...
Replicating Hammerspoon window management with yabai and skhd
I've used Hammerspoon as a window manager for almost 10 years. I decided to explore some of the newer tools in window management to see if I could...