Merge pull request #255813 from linj-fork/feat-kanata-all-device
nixos/kanata: add default value, doc and warning for devices
This commit is contained in:
commit
bba54c4900
@ -9,8 +9,14 @@ let
|
||||
options = {
|
||||
devices = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
example = [ "/dev/input/by-id/usb-0000_0000-event-kbd" ];
|
||||
description = mdDoc "Paths to keyboard devices.";
|
||||
description = mdDoc ''
|
||||
Paths to keyboard devices.
|
||||
|
||||
An empty list, the default value, lets kanata detect which
|
||||
input devices are keyboards and intercept them all.
|
||||
'';
|
||||
};
|
||||
config = mkOption {
|
||||
type = types.lines;
|
||||
@ -162,6 +168,14 @@ in
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
warnings =
|
||||
let
|
||||
keyboardsWithEmptyDevices = filterAttrs (name: keyboard: keyboard.devices == [ ]) cfg.keyboards;
|
||||
existEmptyDevices = length (attrNames keyboardsWithEmptyDevices) > 0;
|
||||
moreThanOneKeyboard = length (attrNames cfg.keyboards) > 1;
|
||||
in
|
||||
optional (existEmptyDevices && moreThanOneKeyboard) "One device can only be intercepted by one kanata instance. Setting services.kanata.keyboards.${head (attrNames keyboardsWithEmptyDevices)}.devices = [ ] and using more than one services.kanata.keyboards may cause a race condition.";
|
||||
|
||||
hardware.uinput.enable = true;
|
||||
|
||||
systemd.services = mapAttrs' mkService cfg.keyboards;
|
||||
|
Loading…
Reference in New Issue
Block a user