Tiny cross-platform (macOS, Windows, Linux/X11) tray app: a global shortcut opens an app, or focuses its most recently used window if it's already running. Design and rationale: @docs/DESIGN.md
- Build / run:
cargo run -- <command>(run,check,list,open <app>,config) - Test:
cargo test - Lint (must be clean):
cargo clippy --all-targets -- -D warnings - Format:
cargo fmt(a hook runs it after every edit to a.rsfile) - Full verification across all three OSes: the
/verifyskill - Size check:
cargo build --release && ls -lh target/release/appkey - Linux end-to-end on Xvfb + Openbox, both in CI and in
/verify:scripts/test-x11.sh <binary>(focus behaviour),scripts/test-settings-ui.sh <binary>(record shortcut → save → daemon reload → shortcut works) - Wayland e2e (containers; see
/verifyand docs/DESIGN.md "Testing Wayland"):scripts/wayland/test-{gnome,kde,hyprland}.sh - See the settings window without screen-recording permission (debug builds):
APPKEY_SCREENSHOT=/tmp/s.png cargo run -- settings, addAPPKEY_SCREENSHOT_SCENE=pickerfor the app picker,=shortcutsfor the Shortcuts tab (on Ubuntu/Mint settings open on Processes),=memoryfor the Memory tab,=processes/=cgroups/=details(the details popup) for the Processes tab (Linux; addAPPKEY_SCREENSHOT_WAIT=4so CPU % is sampled first). Then Read the PNG. Do this after any UI change.
Sole developer, no review process: commit and push straight to main (no feature branches or PRs). Every push to main ships a release, so run /verify first.
Every push to main runs .github/workflows/release.yml: CI → installers on native runners → GitHub Release vMAJOR.MINOR.<run number>. Packaging lives in scripts/package-{linux,macos}.sh, scripts/package-windows.ps1 and packaging/ (Inno Setup, Info.plist, .desktop, icon), plus [package.metadata.deb] / [package.metadata.generate-rpm] in Cargo.toml. Never commit a stamped version: scripts/set-version.sh is for CI only. scripts/package-macos.sh runs fully on this Mac. The Linux script runs in the /verify container (it builds for the container's own arch).
src/main.rs: CLI parsing (hand-rolled, no clap)src/app.rs: the daemon: tray (optional), hotkey registration, event loop (tao on macOS/Windows, plain channel on Linux), config watching, spawning the settings windowsrc/ui/: settings window (appkey settings, egui, separate process).keys.rs= shortcut recording (unit-tested),picker.rs= app chooser,font.rs= system font,devshot.rs= debug-only screenshotssrc/config.rs: TOML config: path, parsing, validation, example. Most unit tests live here.src/matcher.rs: how a configuredappname is compared to what the OS reportssrc/platform/{macos,windows}.rs,src/platform/linux/: one backend per OS, same public functions in each (listed inplatform/mod.rs).desktop_entry.rs/lnk.rsare pure parsers compiled for tests on every host.src/platform/linux/:mod.rspicks a backend per session/desktop.x11.rs,gnome.rs(+packaging/gnome-extension/),kde.rs,hyprland.rsimplementWindowSystem.cinnamon.rs= Super shortcuts as Cinnamon custom keybindings (X11 windows otherwise).reserved.rs= combos Cinnamon/GNOME use themselves (read from GSettings; flagged in settings, reported unavailable by the daemon).portal.rs= GlobalShortcuts portal,xkb.rs= key syntax conversions. See the table in docs/DESIGN.md.src/memory/: Ubuntu/Mint only: low-memory detection (/proc/meminfo, PSI), busy-background-CPU tracking, signalling the user's processes, Magic SysRq (sysrq.rs).procs.rs= process tree → apps, labels (Chrome tabs, IntelliJ, Claude Code…), "left running" detection.uninstall.rs= how an app was installed (snap, Flatpak, .deb, AppImage) and removing it. Parsers compile on every host for tests.cgroup.rs= cgroup tree and the shared memory cap (systemd-runintoapp-appkey.slice). UI:ui/memory.rs(Memory tab),ui/processes.rs(Processes tab;appkey memory [--alert|--busy]opens settings on it)src/hotkeys.rs:Hotkeystrait; global-hotkey on macOS/Windows/X11, desktop-specific ones on Wayland
- Small is a feature. Don't add a dependency without saying why in the PR, and prefer crates already in
Cargo.lock. No GTK on Linux (tray usesksni). Don't re-enable egui'sdefault_fonts. Check binary size impact for new deps (macOS arm64 release ≈ 3.0 MB now). - Platform parity. A change to one backend's public API must be made in all three. Put shared logic in platform-neutral modules where it can be unit-tested on any host.
- We develop on macOS. Windows code is checked with
--target x86_64-pc-windows-msvc, Linux code in a container (see/verify). CI runs all three natively. Never claim Linux/Windows behaviour works without testing it there. A compile check is not a runtime test. - Security:
- Launch commands run without a shell (argv list only).
- The config is refused if other users can write to it.
- Never bypass OS protections: no focus-stealing hacks, no
SendInputtricks, no elevation, no injecting into other processes. If the OS needs the user to grant something, detect it, explain it, and let the OS show its own prompt. - What needs root (the SysRq setting; uninstalling a snap or .deb from the Processes tab) runs fixed argvs through
pkexec, so the desktop shows its own password prompt. appkey's own binary never runs as root. apt removals are dry-run first and refused when they'd remove desktop/system packages. - Every
unsafeblock needs a// SAFETY:comment.
- Errors:
anyhowwith context that tells the user what to do. Hotkey failures go to the tray status/tooltip, not just stderr. In a tray app nobody sees stderr. - Keep
README.md(user-facing) anddocs/DESIGN.md(decisions, platform matrix) in sync with behaviour changes.
rustupcomes from Homebrew (keg-only). Ifcargoisn't found,export PATH="/opt/homebrew/opt/rustup/bin:$PATH".global-hotkeyand the tray must be created on the main thread after the tao loop starts (StartCause::Init).- egui 0.36 API differs from older docs and examples:
App::ui(&mut self, ui, frame),egui::Panel::top/bottom(..).show(ui, ..),run_ui_native. Read the crate source in~/.cargo/registrywhen unsure. - Wayland gotchas (all hit and fixed once, keep them fixed): KDE keeps old portal shortcut ids grabbed (we unregister), and after a cancelled dialog it binds with no keys (we check
trigger_description). GNOME restores focus after the overview hides (re-activate), and Mutter sometimes needs a secondactivate. Hyprland drops runtime binds on reload (re-apply). Portals need our.desktopfile registered. Test env:kwin_waylandmust be copied (file caps), GNOME Shell needs a system bus + mock logind, Hyprland needsvkmsand ignores virtual keyboards for binds. - Cinnamon swallows Super (menu):
XGrabKeywith Mod4 never fires and the settings window never sees the Super press. Super combos go through Cinnamon custom keybindings whose ids must contain "custom", or Cinnamon never unbinds them. Reproduce with a realcinnamon --replaceon Xvfb (apt install cinnamon), not Openbox. Don't setXDG_CONFIG_HOMEin that test: gsettings reads the dconf db from under it, so appkey would see (and write back) an emptycustom-list. - On Linux, winit panics (not errors) if
libxkbcommon-x11is missing. The.debdepends on it, and e2e environments must install it. - X11: always do a round-trip (
get_input_focus().reply()) before dropping a connection that sent requests. Otherwise the server may discard them on disconnect, and focus fails at random. Send real server timestamps with_NET_ACTIVE_WINDOW. - On Linux keep
x11rbon the same minor version asglobal-hotkeyuses (currently 0.13) to avoid two copies. HotKeyids are derived from mods+key, so identical combos written differently (ctrl+avscontrol+A) collide.config::parserejects that.