Skip to content

Development

Keyount is MIT-licensed and standard-library only. One hard rule for contributions: never log the key sequence, and never add network code. Counters only.

Terminal window
make test # run the test suite (no keyboard / libinput needed)
make lint # python compile + bash -n + JSON + systemd unit checks
make bench # full benchmarks (see BENCHMARKS.md)
make bench-quick # small benchmark smoke test (also run in CI)
make install # same as ./install.sh

The suite (80 Python tests + shell tests) feeds sample libinput lines into the counter’s --selftest mode, runs the live counter end-to-end against a fake libinput shim (config, pause, permissions, corrupted files, SIGTERM), unit-tests the shared counting core (src/counter_core.py) and the Windows/macOS key-classification tables directly, checks wordcount output against a temporary $HOME, and statically verifies packaging metadata, the systemd caps, docs/CLI consistency, and the no-network-code rule — so everything runs anywhere, including CI.

src/ counter_core.py (shared logic), keyount.py
(Linux libinput front-end), wordcount (Linux CLI)
ports/ wordcount.py — shared Windows/macOS CLI
windows/ counter_win.py, install/uninstall .ps1, tray.py
macos/ counter_mac.py, install/uninstall .sh, menubar.py
widgets/ KDE plasmoid, GNOME extension, Cinnamon applet,
XFCE/Waybar/Polybar/i3blocks/Conky/MATE/LXQt snippets
scripts/ install-widgets.sh (desktop auto-detect)
systemd/ user service unit
packaging/ PyInstaller standalone-binary builds (build.py)
tests/ unittest + shell tests
benchmarks/ bench.py
site/ this documentation site (Astro + Starlight)
keyboard ──► kernel evdev ──► libinput debug-events --show-keycodes
│
▼
src/keyount.py
(counts only, discards the key)
│
▼
~/.local/share/keyount/YYYY-MM-DD.json
│
┌─────────────────┼─────────────────┐
▼ ▼ ▼
wordcount CLI KDE plasmoid XFCE genmon
(today/week) (30s poll) (30s poll)

Windows replaces the libinput front-end with low-level hooks (WH_KEYBOARD_LL / WH_MOUSE_LL) and macOS with a listen-only CGEventTap; both feed the same src/counter_core.py state machine and write the same JSON.

The docs site lives in site/ (Astro + Starlight). Local dev:

Terminal window
cd site
npm install
npm run dev

It makes zero external requests (system fonts, no analytics, no CDN) — same rules as the counter. Deployment notes are in site/README.md in the repo.

Issues and pull requests are welcome — see CONTRIBUTING.md in the repo. Please keep changes counters-only, stdlib-only, and covered by tests.

MIT © 2026 Chandan Shakya.