nix-config/modules/optional/xserver.nix

50 lines
1.3 KiB
Nix
Raw Normal View History

2023-09-13 17:40:57 +02:00
{
pkgs,
2023-09-26 22:25:58 +02:00
lib,
minimal,
config,
2023-09-26 22:25:58 +02:00
...
}:
lib.optionalAttrs (!minimal) {
2023-09-13 17:40:57 +02:00
# Configure keymap in X11
services.xserver = {
enable = true;
displayManager.startx.enable = true;
autoRepeatDelay = 235;
autoRepeatInterval = 60;
videoDrivers = ["modesetting"];
libinput = {
enable = true;
2023-10-06 11:15:54 +02:00
mouse = {
accelSpeed = "0.5";
accelProfile = "flat";
2023-12-22 01:13:14 +01:00
middleEmulation = false;
2023-10-06 11:15:54 +02:00
};
2023-09-13 17:40:57 +02:00
touchpad = {
accelProfile = "flat";
2023-09-24 20:43:44 +02:00
accelSpeed = "1";
2023-09-13 17:40:57 +02:00
naturalScrolling = true;
disableWhileTyping = true;
};
};
};
services.udev.extraRules = let
exe =
pkgs.writeShellScript "set-key-repeat"
''
if [ -d "/tmp/.X11-unix" ]; then
for D in /tmp/.X11-unix/*; do
file=$(${pkgs.coreutils}/bin/basename $D)
export DISPLAY=":''${file:1}"
user=$(${pkgs.coreutils}/bin/stat -c '%U' "$D")
# sleep to give X time to access the keyboard
(sleep 0.2; ${pkgs.util-linux}/bin/runuser -u "$user" -- ${pkgs.xorg.xset}/bin/xset r rate \
${toString config.services.xserver.autoRepeatDelay} ${toString config.services.xserver.autoRepeatInterval})&
done
fi
'';
in ''
ACTION=="add", SUBSYSTEM=="input", ATTRS{bInterfaceClass}=="03", RUN+="${exe}"
'';
2023-09-13 17:40:57 +02:00
}