kmonad instead of xmodmap

feature/nixinite
Ingolf Wagner 2023-06-02 14:08:07 +02:00
parent 922a5a66e2
commit d80ac3b5a0
Signed by: palo
GPG Key ID: 76BF5F1928B9618B
8 changed files with 99 additions and 74 deletions

View File

@ -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 = [

View File

@ -13,6 +13,7 @@ with lib;
./suspend.nix
./pass.nix
./audio.nix
./kmonad.nix
];
config = mkIf config.components.gui.enable {

View File

@ -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 + <key>
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
];
};

View File

@ -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 + <key>
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

View File

@ -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 ä ß _ _ _ _ _ _ _ _ _ _
_ _ _ ¢ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _)
'';
};
};
}

View File

@ -57,7 +57,6 @@ with lib;
xclip
xtrlock-pam
xorg.xev
xorg.xmodmap
dmenu
arandr

View File

@ -17,6 +17,8 @@ in
{
environment.systemPackages = with pkgs; [
kmonad
((ganttproject-bin.override {
jre = pkgs.openjdk11;
}).overrideAttrs (old: {

49
scripts/kmonad.kbd Normal file
View File

@ -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 ä _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _)