7 releases

new 0.3.2 Nov 23, 2024
0.3.1 Oct 29, 2024
0.2.0 Oct 23, 2024
0.1.2 Oct 16, 2024

#40 in macOS and iOS APIs

Download history 373/week @ 2024-10-13 276/week @ 2024-10-20 138/week @ 2024-10-27 3/week @ 2024-11-03

427 downloads per month

MIT license

13KB
243 lines

SRHD

Simple Rust Hotkey Daemon is a minimal and lightweight key binding service for MacOS similar to skhd. It can be run as in the background using the native launchctl to interact with launchd via a plist file. This functionality has been offloaded to my launchctl Rust library.

[!WARNING]
SRHD is still in active development, and is lacking certain features like hot config reloading and comprehensive error messages. I'm working on rolling those out ASAP. There is also currently a bug where if permission are removed while srhd is running as a service the keyboard and mouse will become unresponsive, and a restart is required.

Installation

The first time srhd starts it will request access to input monitoring. After being granted access you must restart the service for the change to take effect. Secure Keyboard Entry must be disabled in whatever terminal emulator srhd is started from. In alacritty this process is quite hacky, and for some reason requires removing input monitoring in system settings. When something stops working I have found that it can mostly be resolved by toggling access.

Homebrew

brew tap sylvanfranklin/srhd 
brew install srhd
srhd start

Cargo Requires cargo and rust.

cargo install srhd
srhd start

Source Requires cargo and rust.

git clone https://github.com/SylvanFranklin/srhd
cd srhd 
cargo run 

Usage

Usage: srhd [COMMAND]

Commands:
  start    Start launchctl login service
  stop     Stop launchctl login service
  restart  Restart the service
  help     Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version

Configuration

For now config is stored at, other options to be added in the future.

  • $HOME/.config/srhd/srhd.toml

An empty config file will be created automatically the first time srhd is started.

Example Config:

# srhd.toml
[[binding]]
key = "KeyA"
command = "open /Applications/Firefox.app" # or any arbitrary shell script
mods = ["Meta", "Alt"]

Debugging

stdout and stderr can be found at /tmp/$USER_srhd.out.log and /tmp/$USER_srhd.err.log respecively.

Contribution

Contribution is greatly appreciated feel free!

Dependencies

~1.5–2.7MB
~50K SLoC