Skip to content

fix: don't intercept all devices when include/exclude list has no matches#1986

Merged
jtroo merged 1 commit intojtroo:mainfrom
malpern:fix/macos-include-list-fallback
Mar 22, 2026
Merged

fix: don't intercept all devices when include/exclude list has no matches#1986
jtroo merged 1 commit intojtroo:mainfrom
malpern:fix/macos-include-list-fallback

Conversation

@malpern
Copy link
Copy Markdown
Contributor

@malpern malpern commented Mar 21, 2026

Summary

  • When macos-dev-names-include or macos-dev-names-exclude is configured but no connected devices match, kanata was falling back to register_device("") which intercepts all devices
  • This caused kanata to grab the wrong keyboard (e.g., the internal MacBook keyboard when an external keyboard was specified but not connected)
  • Now kanata only falls back to the catch-all registration when no device filter is configured at all — when a filter is present but nothing matches, kanata exits with an error

Fixes #1479

Test plan

  • Configured macos-dev-names-include with a nonexistent device name — kanata now errors out instead of grabbing all devices
  • Configured macos-dev-names-include with a real connected device — kanata correctly grabs only that device and remapping works
  • No include/exclude list — default behavior unchanged (grabs all devices)

Possible follow-up

Linux has linux-continue-if-no-devs-found which lets kanata wait for devices instead of exiting. A cross-platform continue-if-no-devs-found option could be added to support the multi-instance use case where kanata should stay running and pick up the device when it connects.

…ches

When `macos-dev-names-include` or `macos-dev-names-exclude` is configured
but no connected devices match, kanata was falling back to
`register_device("")` which intercepts ALL devices. This caused kanata
to grab the wrong keyboard (e.g., the internal MacBook keyboard when an
external keyboard was specified but not connected).

Now kanata only falls back to the catch-all registration when no device
filter is configured at all. When a filter is present but nothing
matches, kanata exits with an error instead of silently grabbing
everything.

Fixes jtroo#1479

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
malpern added a commit to malpern/kanata that referenced this pull request Mar 21, 2026
Add macOS equivalent of linux-continue-if-no-devs-found. When enabled,
kanata keeps running if no matching devices are found at startup and
automatically captures them when they connect, using driverkit's IOKit
notification system.

This also includes the fix from PR jtroo#1986 (don't fall back to grabbing
all devices when an include/exclude list has no matches).

Depends on psych3r/driverkit#17 for notification subscription support
for not-yet-connected devices.

Relates to jtroo#1479

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
malpern added a commit to malpern/kanata that referenced this pull request Mar 21, 2026
Add macOS equivalent of linux-continue-if-no-devs-found. When enabled,
kanata keeps running if no matching devices are found at startup and
automatically captures them when they connect, using driverkit's IOKit
notification system.

This also includes the fix from PR jtroo#1986 (don't fall back to grabbing
all devices when an include/exclude list has no matches).

Depends on psych3r/driverkit#17 for notification subscription support
for not-yet-connected devices.

Relates to jtroo#1479

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
malpern added a commit to malpern/kanata that referenced this pull request Mar 21, 2026
Add macOS equivalent of linux-continue-if-no-devs-found. When enabled,
kanata keeps running if no matching devices are found at startup and
automatically captures them when they connect, using driverkit's IOKit
notification system.

This also includes the fix from PR jtroo#1986 (don't fall back to grabbing
all devices when an include/exclude list has no matches).

Depends on psych3r/driverkit#17 for notification subscription support
for not-yet-connected devices.

Relates to jtroo#1479

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jtroo jtroo merged commit fc5d709 into jtroo:main Mar 22, 2026
5 checks passed
@malpern malpern deleted the fix/macos-include-list-fallback branch March 22, 2026 04:46
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.

Bug: macos-dev-names-include handle internal keyboard if external keyboard detached

2 participants