From 55df110124d9a66c83e463f0b63659778c5b67b8 Mon Sep 17 00:00:00 2001 From: Erwin Boskma Date: Wed, 17 May 2023 08:06:05 +0200 Subject: [PATCH] Add Kanata to manage keyboard layout --- machines/mimir/configuration.nix | 7 +++- modules/kanata/default.nix | 59 ++++++++++++++++++++++++++++++++ users/erwin/work.nix | 20 +++++------ 3 files changed, 75 insertions(+), 11 deletions(-) create mode 100644 modules/kanata/default.nix diff --git a/machines/mimir/configuration.nix b/machines/mimir/configuration.nix index e3fa775..ce321f5 100644 --- a/machines/mimir/configuration.nix +++ b/machines/mimir/configuration.nix @@ -49,7 +49,12 @@ }; fonts.enable = true; gnome.enable = true; - # greetd.enable = true; + kanata = { + enable = true; + devices = [ + "/dev/input/by-id/usb-04d9_USB-HID_Keyboard-event-kbd" + ]; + }; lightdm.enable = true; networking.enable = true; nix-common = { diff --git a/modules/kanata/default.nix b/modules/kanata/default.nix new file mode 100644 index 0000000..68fe279 --- /dev/null +++ b/modules/kanata/default.nix @@ -0,0 +1,59 @@ +{ config, lib, ... }: +with lib; +let + cfg = config.eboskma.kanata; +in +{ + options.eboskma.kanata = { + enable = mkEnableOption "kanata"; + devices = mkOption { + description = "Devices to enable kanata for"; + type = types.listOf types.path; + }; + }; + + config = mkIf cfg.enable { + services.kanata = { + enable = true; + + keyboards = { + ducky = { + devices = cfg.devices; + + config = '' + (defsrc + esc f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 prtsc scrlck pp calc mute voldwn volu + grv 1 2 3 4 5 6 7 8 9 0 - = bspc ins home pgup nlck kp/ kp* kp- + tab q w e r t y u i o p [ ] \ del end pgdn kp7 kp8 kp9 kp+ + caps a s d f g h j k l ; ' ret kp4 kp5 kp6 + lsft z x c v b n m , . / rsft up kp1 kp2 kp3 kprt + lctl lmet lalt spc ralt rmet rctl lft down rght kp0 kp.) + + (deflayer colemak + esc f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 prtsc @qwe pp calc mute voldwn volu + grv 1 2 3 4 5 6 7 8 9 0 - = bspc ins home pgup nlck kp/ kp* kp- + tab q w f p g j l u y ; [ ] \ del end pgdn kp7 kp8 kp9 kp+ + @cap a r s t d h n e i o ' ret kp4 kp5 kp6 + lsft z x c v b k m , . / rsft up kp1 kp2 kp3 kprt + lctl lmet lalt spc ralt rmet rctl lft down rght kp0 kp.) + + (deflayer qwerty + esc f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 prtsc @col pp calc mute voldwn volu + grv 1 2 3 4 5 6 7 8 9 0 - = bspc ins home pgup nlck kp/ kp* kp- + tab q w e r t y u i o p [ ] \ del end pgdn kp7 kp8 kp9 kp+ + @cap a s d f g h j k l ; ' ret kp4 kp5 kp6 + lsft z x c v b n m , . / rsft up kp1 kp2 kp3 kprt + lctl lmet lalt spc ralt rmet rctl lft down rght kp0 kp.) + + (defalias + cap (tap-hold 100 100 bspc lctl) + col (layer-switch colemak) + qwe (layer-switch qwerty) + ) + ''; + }; + }; + }; + + }; +} diff --git a/users/erwin/work.nix b/users/erwin/work.nix index 28050cb..156fe73 100644 --- a/users/erwin/work.nix +++ b/users/erwin/work.nix @@ -93,12 +93,12 @@ in }; }; - home.keyboard = { - layout = "us,us"; - variant = "colemak,"; - model = "pc105"; - options = [ "ctrl:nocaps" "eurosign:5" "lv5:ralt_switch" "lv3:rwin_switch" "grp:sclk_toggle" "grp_led:scroll" ]; - }; + # home.keyboard = { + # layout = "us,us"; + # variant = "colemak,"; + # model = "pc105"; + # options = [ "ctrl:nocaps" "eurosign:5" "lv5:ralt_switch" "lv3:rwin_switch" "grp:sclk_toggle" "grp_led:scroll" ]; + # }; home.packages = with pkgs; [ atool @@ -229,10 +229,10 @@ in ]; services.xserver = { - layout = "us,us"; - xkbVariant = "colemak,"; - xkbModel = "pc105"; - xkbOptions = "ctrl:nocaps,eurosign:5,lv5:ralt_switch,lv3:rwin_switch,grp:shifts_toggle"; + # layout = "us,us"; + # xkbVariant = "colemak,"; + # xkbModel = "pc105"; + # xkbOptions = "ctrl:nocaps,eurosign:5,lv5:ralt_switch,lv3:rwin_switch,grp:shifts_toggle"; upscaleDefaultCursor = false; exportConfiguration = true;