TLDR; How would one implement a CLI application similar to Karabiner-Elements (Mac) for Linux in Rust?
I just recently moved to Linux from Mac and the one thing I miss the most is the application Karabiner. To easily, and quickly, change between key maps. I constantly switching between English and Swedish keyboard setup, as well as a "modified" Swedish setup I call "code", which I use for programming.
Ive so far used
setxkbmap to switch around keys a bit, but it is a bit clunky.
I also recently started learning Rust and want to start building all my small apps in Rust for a while to get used to the language.
What I want to do
I want to write a CLI application that lets you setup profiles of custom key maps and to easily switch between them.
A key map can either be a pre-defined map such as "English" or "Nordic", but it can also be custom. So the application needs to be able to capture and setup custom mappings (for example the very common remapping of Caps Lock to Escape).
How would you implement something like that in Rust?
Can the keyboard layout be set directly, or would it be better to build a wrapper around something like
setxkbmap? Is it a bad idea altogether?