nix/module/Keyd.nix

103 lines
2.6 KiB
Nix
Raw Normal View History

{
pkgs,
config,
lib,
...
}:
with lib;
let
cfg = config.module.keyd;
in
{
options = {
module.keyd = {
enable = mkEnableOption "Keyboard remaps.";
};
};
2024-05-08 23:42:54 +03:00
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ keyd ];
2024-04-24 04:22:34 +03:00
services.keyd = {
enable = true;
keyboards.default = {
ids = [ "*" ];
settings = {
main = {
backspace = "delete"; # Delete key on backspace.
capslock = "overload(control, esc)"; # Ctrl/esc combo.
compose = "layer(layer_number)"; # Number input layer.
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
# Alternative navigation.
layer_alternative = {
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";
capslock = "capslock";
# space = "macro2(1, 100, macro(space))"; # NOTE: Possible bhop example. Use in per-application, not here.
};
2024-06-25 04:04:39 +03:00
# Media controls.
layer_control = {
space = "playpause";
a = "back";
c = "ejectcd";
d = "forward";
e = "nextsong";
q = "previoussong";
s = "volumedown";
v = "micmute";
w = "volumeup";
x = "stopcd";
z = "mute";
};
2024-04-24 04:22:34 +03:00
# Number inputs.
layer_number = {
q = "7";
w = "8";
e = "9";
a = "4";
s = "5";
d = "6";
z = "1";
x = "2";
c = "3";
space = "0";
"1" = "kpequal";
"2" = "kpslash";
"3" = "kpasterisk";
"4" = "kpminus";
f = "kpenter";
r = "kpplus";
v = "kpcomma";
shift = "backspace";
};
};
};
};
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";
};
}