diff --git a/modules/keyboard/default.nix b/modules/keyboard/default.nix index 9e66b5c4..6bbe0a4c 100644 --- a/modules/keyboard/default.nix +++ b/modules/keyboard/default.nix @@ -1,19 +1,28 @@ -{ pkgs, ... }: +{ + lib, + config, + pkgs, + ... +}: -with pkgs; let - tools = interception-tools; - inherit (interception-tools-plugins) caps2esc; + cfg = config.keyboard; + tools = pkgs.interception-tools; + inherit (pkgs.interception-tools-plugins) caps2esc; in { - services.interception-tools = { - enable = true; - plugins = [ caps2esc ]; - udevmonConfig = '' - - JOB: ${tools}/bin/intercept -g $DEVNODE | ${caps2esc}/bin/caps2esc -m 1 | ${tools}/bin/uinput -d $DEVNODE - DEVICE: - EVENTS: - EV_KEY: [KEY_CAPSLOCK] - ''; + options.keyboard.enable = lib.mkEnableOption "keyboard remapping"; + + config = lib.mkIf cfg.enable { + services.interception-tools = { + enable = true; + plugins = [ caps2esc ]; + udevmonConfig = '' + - JOB: ${tools}/bin/intercept -g $DEVNODE | ${caps2esc}/bin/caps2esc -m 1 | ${tools}/bin/uinput -d $DEVNODE + DEVICE: + EVENTS: + EV_KEY: [KEY_CAPSLOCK] + ''; + }; }; }