Skip to content

touchbar-hw: read the Fn state when the keyboard is grabbed - #70

Open
dnlbtz wants to merge 1 commit into
standardagents:mainfrom
dnlbtz:fn-under-grab
Open

dnlbtz wants to merge 1 commit into
standardagents:mainfrom
dnlbtz:fn-under-grab

Conversation

@dnlbtz

@dnlbtz dnlbtz commented Nov 21, 2026

Copy link
Copy Markdown

Fixes #55.

When keyd or another remapper grabs Apple SPI Keyboard with EVIOCGRAB, the service never sees a KEY_FN event and the Touch Bar stays on the controls. The kernel key state still follows Fn under a grab, so when the Fn descriptor was not readable, process_input() now reads it with function.pressed() (EVIOCGKEY, as on SYN_DROPPED) and passes it to set_fn_pressed(), which ignores an unchanged state.

This relies on wait_events() returning at least every INPUT_WAIT_MS, which the comment in the code says. 546F6E79 checked in #55 that keyd's virtual keyboard does not declare KEY_FN, so following that device instead is not an option.

Tested on a MacBookPro14,3 with CachyOS and keyd 2.6.0, where it has run since 2026-10-23: Fn switches the strip with keyd running. cargo test -p t1-touchbar-hw --features service passes.

A key remapper such as keyd holds the Apple SPI Keyboard with EVIOCGRAB,
so no Fn events reach the service and the Touch Bar never switches to the
function keys. The kernel key state still tracks Fn under a grab, so read
it with EVIOCGKEY on each loop iteration that brought no Fn event.

Fixes standardagents#55

This branch has not been deployed

No deployments
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.

Fn does not switch the Touch Bar while keyd grabs Apple SPI Keyboard (MacBookPro14,3)

1 participant