No description
- Rust 100%
|
|
||
|---|---|---|
| src | ||
| Cargo.lock | ||
| Cargo.toml | ||
| README.md | ||
⌨️ Shiftie
Shiftie is a tiny Rust daemon that watches your keyboard input and turns a dual-shift tap into a synthetic Escape key press. Perfect for people who like modal editors but only have so many fingers! 🧙♂️
✨ Features
- 🔁 Runs as a background daemon with PID and log files stored in your system temp directory (e.g.,
/tmp). - ⌨️ Auto-discovers evdev-compatible keyboards that report both left and right shift keys.
- 🚨 Emits a virtual Escape key press the moment both shift keys are pressed together.
- 🧹 Cleans up its PID file when the daemon exits.
🚀 Getting started
- 📦 Install Rust (https://rustup.rs/) if you don't have it already.
- 🛠️ Build the project:
cargo build --release - 🔐 Ensure you have permission to read from input devices (you may need to run as root or add your user to the appropriate input group).
🕹️ Usage
Shiftie ships with a small CLI built using clap:
cargo run start # default; launches the daemon
cargo run stop # sends SIGTERM to the running daemon
cargo run run # runs in the foreground for debugging
- When starting, Shiftie checks for an existing PID file at something like
/tmp/shifty.pidand refuses to launch if another instance is alive. - The daemon writes logs to the temp directory as
shifty.log. runmode keeps everything in the foreground so you can watch log output in real time.
🧪 How it works
- 🕵️♂️ Enumerates input devices with
evdevand spawns a thread per device to listen for key events. - 🧮 Tracks the state of the left and right shift keys; once both are down simultaneously, an Escape key press/release sequence is emitted through a virtual keyboard created with
evdev's uinput bindings. - 🧱 Uses a guard object to ensure PID files are cleaned up even on panic.
🛑 Stopping the daemon
Running shifty stop sends SIGTERM to the recorded PID and waits (up to 5 seconds) for the process to exit, tidying up the PID file when done.
🧰 Development
- 📚 The code lives in
src/main.rs. - 🧪 Run the daemon in the foreground while developing with:
cargo run -- run - 🧹 Format/lint as you normally would; no extra tooling is required.
Enjoy the new Escape key superpower! 🚀