nix/module/common/Keyd.nix

89 lines
2.2 KiB
Nix
Raw Normal View History

2024-06-23 04:55:57 +03:00
{ pkgs, setting, ... }: {
2024-04-24 04:22:34 +03:00
environment.systemPackages = with pkgs; [ keyd ];
2024-05-08 23:42:54 +03:00
services.keyd = {
enable = true;
keyboards.default = {
ids = [ "*" ];
settings = {
main = {
backspace = "delete"; # Delete key on backspace.
capslock = "overload(control, esc)"; # Ctrl/esc combo.
2024-06-04 22:17:06 +03:00
compose = "layer(layer_number)"; # Number input layer.
2024-06-23 04:55:57 +03:00
esc = "${setting.sysctrl}"; # System controls.
leftcontrol = "overload(layer_alternative, leftcontrol)"; # Alternative layer for home, end etc.
rightcontrol = "layer(layer_control)"; # Media and other controls.
rightshift = "backspace"; # Backspace.
};
2024-04-24 04:22:34 +03:00
# Alternative navigation.
2024-04-24 17:57:39 +03:00
layer_alternative = {
2024-04-24 04:22:34 +03:00
w = "pageup";
a = "home";
s = "pagedown";
d = "end";
x = "cut";
c = "copy";
v = "paste";
h = "left";
j = "down";
k = "up";
l = "right";
esc = "esc";
rightcontrol = "leftcontrol";
2024-05-28 15:00:49 +03:00
capslock = "capslock";
# space = "macro2(1, 100, macro(space))"; # NOTE: Possible bhop example. Use in per-application, not here.
2024-04-24 04:22:34 +03:00
};
# Media controls.
2024-04-24 17:57:39 +03:00
layer_control = {
space = "playpause";
2024-04-25 04:10:00 +03:00
a = "back";
2024-06-09 23:35:53 +03:00
c = "ejectcd";
d = "forward";
2024-04-25 04:10:00 +03:00
e = "nextsong";
q = "previoussong";
2024-06-09 23:35:53 +03:00
s = "volumedown";
w = "volumeup";
2024-05-27 08:37:44 +03:00
x = "stopcd";
z = "mute";
2024-04-24 17:57:39 +03:00
};
2024-04-24 04:22:34 +03:00
2024-06-04 22:17:06 +03:00
# Number inputs.
layer_number = {
q = "1";
w = "2";
e = "3";
a = "4";
s = "5";
d = "6";
z = "7";
x = "8";
c = "9";
space = "0";
"1" = "f13";
"2" = "f14";
"3" = "f15";
"4" = "f16";
"5" = "f17";
"6" = "f18";
"7" = "f19";
"8" = "f20";
"9" = "f21";
"0" = "f22";
"-" = "f23";
"=" = "f24";
enter = "kpenter";
};
};
};
};
2024-04-24 04:58:58 +03:00
# HACK: Workaround for https://github.com/NixOS/nixpkgs/issues/290161
users.groups.keyd = {};
systemd.services.keyd.serviceConfig.CapabilityBoundingSet = [ "CAP_SETGID" ];
2024-05-06 22:11:33 +03:00
# Debug toggle just in case I need it again.
# systemd.services.keyd.environment.KEYD_DEBUG = "1";
}