Mxhkd: a modal key daemon

#1

Hey everyone,

New here. First post!

I’m learning Rust and decided to use it to write a modal key daemon for Linux/X11. It’s like sxhkd but rather than using chords, it toggles between modes: one mode doesn’t do much, it just listens on a “mode toggle”, and the other mode listens on the entire keyboard waiting for a binding to trigger a command.

The idea came from imagining a window manager that would work (kind of) like vim. However writing a window manager is a lot of work, and a key daemon is a lot less code. By toggling between modes I can get more usage out of my keyboard without moving my hands too much, so it helps stress my hands less after many hours of sitting at the computer :slight_smile:

It uses the xcb bindings library to achieve most of the functionality. I have to say I’m quite impressed at how fast I could get up and running with Rust. The bindings to the lower-level libraries are fantastic. What I found hard: writing a custom serde::Deserialize trait for an enum (I’m still trying that out, I haven’t quite got it right).

I’ve been using it in anger for some time now and I’m quite happy with it. The code itself is still quite ugly but IMO usable. I will appreciate any tips/recommendations/issues encountered. I’ve tried to document it and provide a somewhat sensible configuration example. Unfortunately there’s a runtime dependency on xmodmap which might not work entirely as expected. Next up I plan to remove that dependency and just use whatever is provided by xlib.

The link: https://github.com/carlosdagos/mxhkd

Cheers.

Carlos

1 Like