Skip to content

Notify when the evdev hotkey can't open any keyboard - #884

Merged
peteonrails merged 1 commit into
peteonrails:rc/1.3.0from
crmne:fix/notify-hotkey-access
Nov 17, 2026
Merged

peteonrails merged 1 commit into
peteonrails:rc/1.3.0from
crmne:fix/notify-hotkey-access

Conversation

@crmne

@crmne crmne commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

With [hotkey] enabled = true and the user not in the input group (or added to it without logging out since), the daemon starts and reports itself running, but the hotkey does nothing. The only trace is Hotkey listener error: No keyboard device found in /dev/input/ in the journal, which says nothing about the input group even though HotkeyError::DeviceAccess already carries that fix.

Root cause

  • src/hotkey/evdev_listener.rs:270-272: try_open_device drops PermissionDenied without recording it.
  • src/hotkey/evdev_listener.rs:189: with no device opened, DeviceManager::new returns NoKeyboard, so a permission problem and a machine without a keyboard look the same.
  • src/hotkey/evdev_listener.rs:128-138: DeviceManager::new ran inside the spawn_blocking task, so its error was only logged there. start() had already returned Ok, and the daemon's own "Failed to start hotkey listener" branch (src/daemon.rs:4007) could never fire for it.

After startup the listener loop never returns an error (it only exits on stop or channel close), so startup was the only silent failure point.

What changed

  • DeviceManager::new() now runs in start(), and the manager moves into the listener task. Any failure to open a keyboard comes back to the daemon as an error.
  • The manager remembers the first device that failed with EACCES. When no keyboard was opened, the new src/hotkey/access.rs decides which error to return:
    • no device denied: NoKeyboard
    • not in the input group: DeviceAccess (the existing usermod message)
    • listed in the group database (members or primary gid) but the process does not have the group: new InputGroupInactive, which asks the user to log out and back in
    • the process has the group and is still denied: new DeviceDenied, pointing at ls -l /dev/input/event*
      Group lookup uses NSS through nix::unistd::Group/User (adds nix's user feature, no new crate). The classification is a pure function with unit tests.
  • Every error message now also offers the alternative: bind voxtype record toggle in the compositor and set [hotkey] enabled = false.
  • The daemon's existing start-failure branch logs the error and sends one desktop notification through notification::send_status (normal urgency, 15 s). It fires once per daemon start, only when the hotkey is enabled. With [hotkey] enabled = false nothing changes, since no listener is created.
  • "Listening for hotkey: ..." is no longer logged when the listener failed to start.
  • docs/TROUBLESHOOTING.md describes the notification and its four cases.

voxtype status is unchanged. The state file holds a single word that Waybar and the OSD parse, so it isn't a natural place for this.

Notification text

Title for all cases: Voxtype: hotkey not working

  • Not in the group: Permission denied reading keyboards in /dev/input. Run sudo usermod -aG input $USER, then log out and back in. Or bind voxtype record toggle in your compositor and set [hotkey] enabled = false.
  • Needs re-login: You are in the 'input' group, but this session started before you were added. Log out completely and back in (or reboot). Or bind voxtype record toggle in your compositor and set [hotkey] enabled = false.
  • In the group, still denied: Permission denied opening /dev/input/event0 although voxtype has the 'input' group. Check ls -l /dev/input/event*. Or bind voxtype record toggle in your compositor and set [hotkey] enabled = false.
  • No keyboard: No keyboard found in /dev/input. Plug one in and restart voxtype. Or bind voxtype record toggle in your compositor and set [hotkey] enabled = false.

How it was verified

  • cargo fmt, cargo test (all pass, 8 new tests in hotkey::access), and cargo clippy --all-targets -- -D warnings -A clippy::double_must_use. The allowed lint is a pre-existing async_trait warning from the current toolchain in src/audio/mod.rs and src/output/mod.rs, which this PR doesn't touch.
  • Ran the real debug daemon under bwrap with a temporary config, XDG_RUNTIME_DIR and a stub notify-send that records its arguments. A mode-000 file bind-mounted as /dev/input/event0 makes open() fail with EACCES. bwrap's user namespace drops the supplementary groups, which reproduces the re-login case. A fake /etc/group without the user gives the not-a-member case, and one that maps input to the overflow gid gives the "has the group, still denied" case. An empty tmpfs /dev/input gives the no-keyboard case. All four logged the right error and sent exactly the notification above. A run against the real /dev/input opened the keyboards and sent no notification.

@crmne
crmne requested a review from peteonrails as a code owner October 20, 2026 07:49
crmne added a commit to crmne/voxtype that referenced this pull request Oct 20, 2026
crmne added a commit to crmne/voxtype that referenced this pull request Oct 21, 2026
Brings in transcribe.cpp (Cohere GGUF, peteonrails#792) and the 1.2.0 cleanup
pipeline, so the Parakeet GGUF branch can sit on top.

Conflicts:
- notification.rs: kept the D-Bus delivery of peteonrails#881 and added 1.2.0's
  body_markup probe.
- output: the cleanup diff now runs through the titled notification
  of peteonrails#880, so the clipboard-fallback label keeps the edit count.
- evdev: peteonrails#884 opens devices in start(); it now passes the watched keys.
- setup: peteonrails#880's pure build_output_chain gains 1.2.0's compositor and
  /dev/uinput checks.
- parakeet.rs: kept peteonrails#891's pause-cut windows, which also cover timed
  transcription; rc's max_window_secs/window_overlap_secs are unused here.
- ci.yml: requires both clippy-features and macos-check.
The listener skipped every device it got EACCES on, then failed inside
its own thread with "No keyboard device found". The daemon reported
itself running while the hotkey did nothing, and the only trace was a
journal line that never mentioned the 'input' group.

Open the keyboards in start() instead of in the listener thread, so
the daemon gets the error back. When nothing could be opened and at
least one device was denied, tell apart a user who is not in the
'input' group, one who is in /etc/group but whose session predates it,
and one whose process already has the group. The daemon logs the error
and shows a desktop notification with the fix and the compositor
keybinding alternative. "Listening for hotkey" is no longer logged
when the listener failed.
crmne added a commit to crmne/voxtype that referenced this pull request Nov 17, 2026
@crmne
crmne force-pushed the fix/notify-hotkey-access branch from 6839205 to 0e80182 Compare November 17, 2026 01:09
@crmne
crmne changed the base branch from dev to rc/1.3.0 November 17, 2026 01:09
@crmne

crmne commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto rc/1.3.0 and retargeted there from dev, since dev is 414 commits behind the 1.3.0 work. Nothing here was covered upstream, so the change is the same, ported to the refactored code.

@peteonrails
peteonrails merged commit b2016c3 into peteonrails:rc/1.3.0 Nov 17, 2026
6 of 9 checks passed
peteonrails added a commit that referenced this pull request Nov 17, 2026
Since PR #884 a daemon that cannot open a keyboard posts "Voxtype:
hotkey not working" on every start. People who bind `voxtype record
toggle` in their compositor and are not in the `input` group, a setup
voxtype's own onboarding produces, have a working hotkey and were told
otherwise at each login and restart.

Retitle it "Voxtype: built-in hotkey unavailable" and have the body say
that [hotkey] enabled = false or --no-hotkey turns the built-in hotkey
off and silences it. Record the notified cause in a marker under the
state directory, the scheme the doctor startup summary uses, so it is
shown once per install; a successful start clears the marker so a later
breakage is reported again. The warning is still logged on every start.
peteonrails added a commit to jaypopat/voxtype that referenced this pull request Nov 22, 2026
Brings in rc/1.3.0 at 142005c: 15 merged PRs (peteonrails#879 to peteonrails#897), most of
which add desktop notifications for failures that used to be silent, and
the fixes after them. Both sides' behaviour is kept. History still
records what was delivered, and the new notices still fire.

Conflicts:

- src/app/dispatch.rs: kept both sets of new command arms, paste-last and
  history from this branch and doctor from rc/1.3.0.
- src/lib.rs: kept all three new modules (failed_recording,
  failure_notice, history).
- src/hotkey/evdev_listener.rs: rc/1.3.0 opens the keyboards in start()
  so a missing 'input' group is reported (peteonrails#884). The paste-last keys are
  added to the watched set there; the loop keeps only its held-modifier
  state.
- src/output/mod.rs: one chain runner instead of two.
  output_with_fallback_report (peteonrails#880) now returns its report together
  with this branch's Delivered, and deliver_with_fallback and
  output_with_fallback are thin wrappers over it.
- src/daemon.rs: dictation output calls output_with_fallback_report once.
  The history note is filled from Delivered (driver, fell_back, the text
  as delivered) and the clipboard-fallback and nothing-delivered notices
  from the report.
- src/setup/mod.rs: `voxtype setup check` prints the doctor report (peteonrails#887)
  and then this branch's Dictation History guidance, unchanged.
  `voxtype doctor` itself is as rc/1.3.0 wrote it.

Changed to build, not conflicted:

- src/output/fallback.rs: run_chain takes the history delivery context,
  captures the focused app around each attempt as the old loop did, and
  returns Delivered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants