Skip to content

Per-keyboard rule targeting (Karabiner-like) — device-aware predicates for switch/actions #63

@malpern

Description

@malpern

Problem

Kanata can only select devices at startup (macos-dev-names-*, linux-dev-names-*). Within a single process there’s no way to target or exclude specific keyboards inside rules (layers, overrides, aliases, etc.). Users want Karabiner-style per-device behavior (e.g., external board uses layer X, built-in uses layer Y) without running multiple Kanata instances.

Goal / Outcome

Provide a device-aware predicate that can be used in switch and (over time) other action contexts, so config authors can scope rules to specific keyboards by name/hash/path.

Scope

  • Expose device metadata on events (macOS DriverKit product name/hash; Linux evdev name/path; Windows optional/TBD).
  • Add a device-matching predicate (device?, if-device, or switch-device) usable in switch (v1) and extendable to other constructs (e.g., conditionals, overrides).
  • Keep feature opt-in; default configs unchanged.
  • Docs + samples showing include/exclude patterns and fallbacks.
  • Tests: parser + runtime with macOS DriverKit stub and Linux evdev mock.

Acceptance Criteria

  • A single Kanata process can apply different layers/actions based on the originating keyboard.
  • Clear errors/warnings when a referenced device isn’t present.
  • No measurable perf regression in the hot path (device lookup O(1)).

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions