nix/config/Keyd.nix

99 lines
2.3 KiB
Nix
Raw Normal View History

{
2024-11-04 04:37:29 +03:00
config,
lib,
pkgs,
...
}: let
cfg = config.module.keyd;
in {
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [
keyd
];
2024-04-24 04:22:34 +03:00
2024-11-04 04:37:29 +03:00
services.keyd = {
enable = true;
keyboards.default = {
ids = [ "*" ];
settings = {
# NOTE: Use `wev` to find key names.
main = {
backspace = "delete"; # Delete key on backspace.
capslock = "overload(control, esc)"; # Ctrl/esc combo.
compose = "layer(layer_number)"; # Number input layer.
2024-11-08 10:56:30 +03:00
delete = "backslash";
2024-11-04 04:37:29 +03:00
esc = "print"; # 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
2024-11-04 04:37:29 +03:00
# Alternative navigation.
layer_alternative = {
a = "home";
c = "copy";
d = "end";
h = "left";
j = "down";
k = "up";
l = "right";
s = "pagedown";
v = "paste";
w = "pageup";
x = "cut";
esc = "esc";
rightcontrol = "leftcontrol";
capslock = "capslock";
};
2024-06-25 04:04:39 +03:00
2024-11-04 04:37:29 +03:00
# Media controls.
layer_control = {
a = "back";
c = "ejectcd";
d = "forward";
e = "nextsong";
q = "previoussong";
s = "volumedown";
v = "micmute";
w = "volumeup";
x = "stopcd";
z = "mute";
space = "playpause";
};
2024-04-24 04:22:34 +03:00
2024-11-04 04:37:29 +03:00
# Number inputs.
layer_number = {
"1" = "kpequal";
"2" = "kpslash";
"3" = "kpasterisk";
"4" = "kpminus";
a = "4";
c = "3";
d = "6";
e = "9";
f = "kpenter";
q = "7";
r = "kpplus";
s = "5";
v = "kpcomma";
w = "8";
x = "2";
z = "1";
shift = "backspace";
space = "0";
};
};
};
};
2024-04-24 04:58:58 +03:00
2024-11-04 04:37:29 +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
2024-11-04 04:37:29 +03:00
# Debug toggle just in case I need it again.
# systemd.services.keyd.environment.KEYD_DEBUG = "1";
};
}