diff --git a/flake.nix b/flake.nix index 3d5cee2..56a40cf 100644 --- a/flake.nix +++ b/flake.nix @@ -137,6 +137,7 @@ sops.defaultSopsFile = lib.mkForce "${secrets}/secrets/${name}.yaml"; imports = [ sops-nix.nixosModules.sops + kmonad.nixosModules.default ]; }; in @@ -153,6 +154,8 @@ polygon-art = polygon-art.packages.${pkgs.system}; landingpage = landingpage.packages.${pkgs.system}.plain; trilium-server = nixpkgs-unstable.legacyPackages.${pkgs.system}.trilium-server; + kmonad = kmonad.packages.${pkgs.system}.kmonad; + }) ]; }; @@ -200,18 +203,8 @@ imports = [ grocy-scanner.nixosModule nixos-hardware.nixosModules.framework-12th-gen-intel - #retiolum.nixosModules.retiolum - #kmonad.nixosModules.default private_assets.nixosModules.jobrad ]; - # todo : check out => https://github.com/terlar/nix-config/blob/ad35fbfc20e58626eb9fbd5f67716bc07bb98fc9/home-manager/modules/profiles/user/terje/keyboards.nix - #services.kmonad = { - # enable = false; - # keyboards.laptop-keyboard = { - # name = "laptop-keyboard"; - # device = ""; - # }; - #}; home-manager.users.mainUser = { imports = [ diff --git a/nixos/components/gui/default.nix b/nixos/components/gui/default.nix index 36b777d..a25dd3f 100644 --- a/nixos/components/gui/default.nix +++ b/nixos/components/gui/default.nix @@ -13,6 +13,7 @@ with lib; ./suspend.nix ./pass.nix ./audio.nix + ./kmonad.nix ]; config = mkIf config.components.gui.enable { diff --git a/nixos/components/gui/home-manager/default.nix b/nixos/components/gui/home-manager/default.nix index f4c3904..ce5902e 100644 --- a/nixos/components/gui/home-manager/default.nix +++ b/nixos/components/gui/home-manager/default.nix @@ -1,32 +1,5 @@ { pkgs, lib, config, ... }: with lib; -let - # todo : use kmonad - xmodmapConfig = pkgs.writeText "xmodmap" '' - ! - ! Swap Caps_Lock and Control_L - ! - - ! replace capslock keys with Escape Keys - ! remove Lock = Caps_Lock - clear Lock - add Lock = Scroll_Lock - - keysym Caps_Lock = Escape - - ! Set Right function Key to Windows-key - keycode 135 = Super_R NoSymbol Super_R NoSymbol Super_R - - ! Map umlauts to RIGHT ALT + - keycode 108 = Mode_switch - keysym e = e E EuroSign - keysym c = c C cent - keysym a = a A adiaeresis Adiaeresis - keysym o = o O odiaeresis Odiaeresis - keysym u = u U udiaeresis Udiaeresis - keysym s = s S ssharp - ''; -in { imports = [ @@ -219,9 +192,6 @@ in # todo : still needed? home.file.".xprofile".text = '' - # load keyboard mappings - ${pkgs.xorg.xmodmap}/bin/xmodmap ${xmodmapConfig} - # to allow sudo commands to access X # todo : only allow the browsers and rambox access ${pkgs.xorg.xhost}/bin/xhost + @@ -281,11 +251,6 @@ in environment.systemPackages = let - fixKeyboard = pkgs.writeScriptBin "fix-Keyboard" # sh - '' - ${pkgs.xorg.xmodmap}/bin/xmodmap ${xmodmapConfig} - ''; - fixXhost = pkgs.writeScriptBin "fix-xhost" # sh '' ${pkgs.xorg.xhost}/bin/xhost + &> /dev/null @@ -294,8 +259,6 @@ in fixX = pkgs.writeScriptBin "fix-X" # sh '' - ${fixKeyboard}/bin/fix-Keyboard - for file in `ls ~/.screenlayout` do echo $file @@ -313,7 +276,6 @@ in [ fixX fixXhost - fixKeyboard ]; }; diff --git a/nixos/components/gui/home-manager/i3.nix b/nixos/components/gui/home-manager/i3.nix index 2b3b957..d620201 100644 --- a/nixos/components/gui/home-manager/i3.nix +++ b/nixos/components/gui/home-manager/i3.nix @@ -314,33 +314,8 @@ in # autorandr --change # automatically detects the setup "${cfg.config.modifier}+BackSpace" = let - xmodmapConfig = pkgs.writeText "xmodmap" '' - ! - ! Swap Caps_Lock and Control_L - ! - - ! replace capslock keys with Escape Keys - ! remove Lock = Caps_Lock - clear Lock - add Lock = Scroll_Lock - - keysym Caps_Lock = Escape - - ! Set Right function Key to Windows-key - keycode 135 = Super_R NoSymbol Super_R NoSymbol Super_R - - ! Map umlauts to RIGHT ALT + - keycode 108 = Mode_switch - keysym e = e E EuroSign - keysym c = c C cent - keysym a = a A adiaeresis Adiaeresis - keysym o = o O odiaeresis Odiaeresis - keysym u = u U udiaeresis Udiaeresis - keysym s = s S ssharp - ''; script = pkgs.writers.writeBash "autorandr" '' ${pkgs.autorandr}/bin/autorandr --change - ${pkgs.xorg.xmodmap}/bin/xmodmap ${xmodmapConfig} ${backgroundCommand} ''; in diff --git a/nixos/components/gui/kmonad.nix b/nixos/components/gui/kmonad.nix new file mode 100644 index 0000000..a3bf8e2 --- /dev/null +++ b/nixos/components/gui/kmonad.nix @@ -0,0 +1,44 @@ +{ + services.kmonad = { + enable = true; + keyboards.dasKeyboard = { + device = "/dev/input/by-id/usb-Metadot_-_Das_Keyboard_Das_Keyboard-event-kbd"; + defcfg = { + enable = true; + fallthrough = true; + allowCommands = true; + }; + config = '' + (defsrc + grv 1 2 3 4 5 6 7 8 9 0 - = bspc + tab q w e r t y u i o p [ ] \ + caps a s d f g h j k l ; ' ret + lsft z x c v b n m , . / rsft + lctl lmet lalt spc ralt rmet cmp rctl + ) + + (defalias sym (layer-toggle symbols)) + + (deflayer qwerty + grv 1 2 3 4 5 6 7 8 9 0 - = bspc + tab q w e r t y u i o p [ ] \ + esc a s d f g h j k l ; ' ret + lsft z x c v b n m , . / rsft + lctl lmet lalt spc @sym rmet cmp rctrl + ) + + ;; sz + ;; cent + ;; tm + ;; ^2 ^3 ... + (deflayer symbols + _ _ _ _ _ _ _ _ _ _ _ _ _ _ + _ _ _ € _ ™ _ ü _ ö _ _ _ _ + caps ä ß _ _ _ _ _ _ _ _ _ _ + _ _ _ ¢ _ _ _ _ _ _ _ _ + _ _ _ _ _ _ _ _) + ''; + }; + + }; +} diff --git a/nixos/components/gui/xorg/default.nix b/nixos/components/gui/xorg/default.nix index 8f354d2..18e9d20 100644 --- a/nixos/components/gui/xorg/default.nix +++ b/nixos/components/gui/xorg/default.nix @@ -57,7 +57,6 @@ with lib; xclip xtrlock-pam xorg.xev - xorg.xmodmap dmenu arandr diff --git a/nixos/machines/cream/packages.nix b/nixos/machines/cream/packages.nix index 51c1947..010bc88 100644 --- a/nixos/machines/cream/packages.nix +++ b/nixos/machines/cream/packages.nix @@ -17,6 +17,8 @@ in { environment.systemPackages = with pkgs; [ + kmonad + ((ganttproject-bin.override { jre = pkgs.openjdk11; }).overrideAttrs (old: { diff --git a/scripts/kmonad.kbd b/scripts/kmonad.kbd new file mode 100644 index 0000000..65e454d --- /dev/null +++ b/scripts/kmonad.kbd @@ -0,0 +1,49 @@ + +(defcfg + ;; For Linux + input (device-file "/dev/input/by-id/usb-Metadot_-_Das_Keyboard_Das_Keyboard-event-kbd") + output (uinput-sink "My KMonad output" + ;; To understand the importance of the following line, see the section on + ;; Compose-key sequences at the near-bottom of this file. + "/run/current-system/sw/bin/sleep 1 && /run/current-system/sw/bin/setxkbmap -option compose:ralt") + cmp-seq ralt ;; Set the compose key to `RightAlt' + cmp-seq-delay 5 ;; 5ms delay between each compose-key sequence press + + ;; Comment this if you want unhandled events not to be emitted + fallthrough true + + ;; Set this to false to disable any command-execution in KMonad + allow-cmd true +) + +(defsrc + grv 1 2 3 4 5 6 7 8 9 0 - = bspc + tab q w e r t y u i o p [ ] \ + caps a s d f g h j k l ; ' ret + lsft z x c v b n m , . / rsft + lctl lmet lalt spc ralt rmet cmp rctl +) + +(defalias sym (layer-toggle symbols)) + +(deflayer qwerty + grv 1 2 3 4 5 6 7 8 9 0 - = bspc + tab q w e r t y u i o p [ ] \ + esc a s d f g h j k l ; ' ret + lsft z x c v b n m , . / rsft + lctl lmet lalt spc @sym rmet cmp rctrl +) + +;; sz +;; cent +;; tm +;; ^2 ^3 ... +(deflayer symbols + _ _ _ _ _ _ _ _ _ _ _ _ _ _ + _ _ _ € _ _ _ ü _ ö _ _ _ _ + caps ä _ _ _ _ _ _ _ _ _ _ _ + _ _ _ _ _ _ _ _ _ _ _ _ + _ _ _ _ _ _ _ _) + + +