nix/config/Keyd.nix

99 lines
2.6 KiB
Nix
Raw Permalink Normal View History

{
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
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.
delete = "backslash";
esc = "print"; # System controls.
2024-12-24 04:10:47 +03:00
left = "layer(layer_number)"; # Number input layer.
leftcontrol = "overload(layer_alternative, leftcontrol)"; # Alternative layer for home, end etc.
2024-12-24 04:26:39 +03:00
right = "compose";
rightcontrol = "layer(layer_control)"; # Media and other controls.
rightshift = "backspace"; # Backspace.
};
2024-04-24 04:22:34 +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
# 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
# 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
# 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";
};
}