rusty-keys/README.md

61 lines
2.8 KiB
Markdown
Raw Normal View History

2017-09-22 00:30:56 -04:00
rusty-keys
2016-04-25 11:57:45 -04:00
======
2017-09-22 00:30:56 -04:00
uinput level keyboard mapper for linux, with advanced caps lock and shift swapping behavior
This is the only keymapper I am aware of capable of implementing this layout:
![Unix Programmer's Dvorak](https://www.moparisthebest.com/kbs/programmer-dvorak-NoSecondary-NumpadStandard-NoSwap-StandardNums-SwapAt-SwapPipe.svg)
The Problem
-----------
2017-11-17 00:03:45 -05:00
If you ever have mapped keys on linux, you know that there is the console keymap (loadkeys) and the X keymap (setxkbmap),
2017-09-22 00:30:56 -04:00
also things like SDL and Virtualbox grab the input directly and respect no maps. Lastly I want to revert to QWERTY when
holding ctrl so ctrl+c works just like normal, without remapping all programs to ctrl+j. Linux keymaps cannot do this either.
The Solution
------------
1. Grab a keyboard device directly so only we can read events from it.
2017-11-17 00:03:45 -05:00
2. Create a new keyboard input device with uinput, this looks identical to any other keyboard device to anything running on the box.
3. Read input_events from the real device, map them, send them to our created device.
2017-09-22 00:30:56 -04:00
This solution is what rusty-keys implements, it works in ttys, in X, in virtualbox even running windows or whatever,
on SDL games, it will work literally everywhere, because rusty-keys just creates a regular keyboard.
How to run
----------
2017-11-17 00:03:45 -05:00
When ran, it will read a keymap.toml configuration file, refer to example and tweak to suit.
2016-04-25 11:57:45 -04:00
```
2017-11-17 00:03:45 -05:00
Usage: rusty-keys [options] [device_files...]
2017-09-22 00:30:56 -04:00
Options:
-h, --help prints this help message
-v, --version prints the version
2017-11-17 00:03:45 -05:00
-c, --config FILE specify the keymap config file to use (default:
/etc/rusty-keys/keymap.toml)
2017-09-22 00:30:56 -04:00
```
2017-11-17 00:03:45 -05:00
when ran without specifying input devices, it maps all currently connected keyboards, and watches /dev/input/ with
inotify and starts mapping any new keyboards that are plugged in forever, until you kill it:
2017-09-22 00:30:56 -04:00
`rusty-keys`
2017-11-17 00:03:45 -05:00
or you can specify one or multiple input devices, and it will run until all are disconnected, then stop:
`rusty-keys /dev/input/event0` or `rusty-keys /dev/input/event0 /dev/input/event2`
2017-09-22 00:30:56 -04:00
2017-11-17 00:03:45 -05:00
An example systemd service is in systemd/rusty-keys.service, enable it to have mapped keyboards all the time.
2017-09-22 23:57:26 -04:00
How to install
--------------
* `cargo install rusty-keys`
2017-11-17 00:03:45 -05:00
* Arch Linux [rusty-keys](https://aur.archlinux.org/packages/rusty-keys/) [rusty-keys-git](https://aur.archlinux.org/packages/rusty-keys-git/)
2017-09-22 23:57:26 -04:00
2017-09-22 00:30:56 -04:00
License
-------
AGPLv3 for now, message me if you have a problem with this
Notes
-----
Technically this is a re-implementation of a [previous](https://code.moparisthebest.com/moparisthebest/uinput-mapper/src/master/uinputmapper/keymapper.py) [python](https://code.moparisthebest.com/moparisthebest/uinput-mapper/src/master/keymaps/dvorak.py) [program](https://code.moparisthebest.com/moparisthebest/uinput-mapper/src/master/input-read#L151)
I had been using for 3 years previously.