Repository navigation
feat(auto-input): add per-app keyboard mode for the top row - #487
Conversation
Fixed rules can now choose a keyboard mode per app: follow the system, use standard F1-F12 function keys, or keep the MacBook top-row shortcuts. The mode applies while the rule's app is frontmost, and the top row returns to its previous setting when you switch away. Writing the preference alone is only re-read at login, so the new controller also updates the live HIDFKeyMode value through IOKit to apply the change immediately.
|
Thanks for adding per-app keyboard modes! I reproduced two issues that would be good to fix before merging:
These affect the global keyboard setting, so the impact can extend to other apps. The existing 23 tests pass; three additional checks reproduce these cases using a mock controller, without changing real keyboard settings. |
Capture the system function-key setting only when a rule first takes control, keep it while switching between rule-controlled apps, and clear it after a successful restore. This preserves a setting the user changes in System Settings while no rule is active. Record the applied mode only after the system write succeeds, keep the original value when a restore fails so a later refresh can retry, and surface a localized error until a retry succeeds.
|
Thanks for the review — both issues are fixed in 734297c.
Added four mock-controller tests: latest System Settings value after an unmanaged change, preserving the original value across two rule apps, retrying a failed apply, and retrying a failed restore. Verification: |
|
@ggbond268 PTAL again |
Problem and result
Auto Input rules could only pick an input source, so anyone who keeps some apps (IDE, terminal, games) on standard function keys had to flip the global "Use F1, F2, etc. as standard function keys" setting by hand whenever they switched apps.
Each fixed rule can now also choose a keyboard mode: follow the system, use standard F1–F12 function keys, or keep the MacBook top-row shortcuts. The mode applies while the rule's app is frontmost, and the top row returns to the setting it had before when you switch away.
Changes
keyboardMode(system,standardFunctionKeys,mediaShortcuts). Rules saved by earlier versions decode assystem, so existing stores keep working.SystemAutoInputFunctionKeyController, which reads and writes the globalcom.apple.keyboard.fnStatepreference. macOS only re-reads that preference at login, so the controller also updates the liveHIDFKeyModevalue onIOHIDSystemthrough IOKit, the same mechanism System Settings uses, and the change takes effect at once.AutoInputControllerapplies the rule's mode on app activation and restores the previous top-row behavior on stop, when the plugin goes background, or when the frontmost app has no keyboard-mode rule. Application monitoring now also runs when only keyboard-mode rules exist.Permissions and compatibility:
IOHIDSystemparameter access needs no extra entitlement and Auto Input is not sandboxed. No new workspace, catalog, or manifest fields.Verification
make build-plugin PLUGIN=AutoInputmake test TEST_FILTER="AutoInputStoreTests AutoInputControllerTests AutoInputPluginPanelTests"— 23 tests pass, including new coverage for keyboard-mode persistence, decoding older rule payloads, and apply/restore behavior.make script-tests— 232 tests pass, including changelog and 12-language localization validation.HIDFKeyModeproperty onIOHIDSystem.UI evidence
The rule row now hosts both pickers on one line, so a narrow window truncates the app name before the controls. Screenshots are not attached in this PR yet; I can add light and dark captures of the updated rules row if maintainers want them.
Checklist