feat: added automatic keyboard repeat set

This commit is contained in:
Patrick 2023-10-10 02:28:07 +02:00
parent 0566da11d1
commit 5105004d98
Signed by: patrick
GPG key ID: 451F95EFB8BECD0F
4 changed files with 40 additions and 16 deletions

View file

@ -1,6 +1,8 @@
{ {
pkgs,
lib, lib,
minimal, minimal,
config,
... ...
}: }:
lib.optionalAttrs (!minimal) { lib.optionalAttrs (!minimal) {
@ -26,4 +28,21 @@ lib.optionalAttrs (!minimal) {
}; };
}; };
services.autorandr.enable = true; services.autorandr.enable = 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")
${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}"
'';
} }

View file

@ -7,12 +7,7 @@
exe = exe =
pkgs.writeShellScript "set-wallpaper" pkgs.writeShellScript "set-wallpaper"
'' ''
if [ -d "/tmp/.X11-unix" ]; then ${pkgs.feh}/bin/feh --no-fehbg --bg-fill --randomize --recursive ${wallpaper-folder}/
for D in /tmp/.X11-unix/*; do
file=$(${pkgs.coreutils}/bin/basename $D)
DISPLAY=":''${file:1}" ${pkgs.feh}/bin/feh --no-fehbg --bg-fill --randomize --recursive ${wallpaper-folder}/
done
fi
''; '';
in { in {
systemd.user = { systemd.user = {
@ -22,7 +17,6 @@ in {
Description = "Set a random wallpaper every 3 minutes"; Description = "Set a random wallpaper every 3 minutes";
}; };
Timer = { Timer = {
OnActiveSec = "2 sec";
OnUnitActiveSec = "3 min"; OnUnitActiveSec = "3 min";
}; };
Install.WantedBy = ["timers.target"]; Install.WantedBy = ["timers.target"];
@ -38,6 +32,7 @@ in {
ExecStart = ExecStart =
exe; exe;
}; };
Install.WantedBy = ["graphical-session.target"];
}; };
}; };
}; };

View file

@ -4,11 +4,6 @@
# #
# Executed by startx (run your window manager from here) # Executed by startx (run your window manager from here)
xset m 1 0
xsetroot -solid '#000000'
#
xset r rate 235 60
# copied from nixos wiki # copied from nixos wiki
# https://nixos.wiki/wiki/Using_X_without_a_Display_Manager # https://nixos.wiki/wiki/Using_X_without_a_Display_Manager
if test -z "$DBUS_SESSION_BUS_ADDRESS"; then if test -z "$DBUS_SESSION_BUS_ADDRESS"; then
@ -20,7 +15,4 @@ if command -v dbus-update-activation-environment >/dev/null 2>&1; then
dbus-update-activation-environment DISPLAY XAUTHORITY dbus-update-activation-environment DISPLAY XAUTHORITY
fi fi
autorandr -c
streamdeck --no-ui &
systemctl --user start set-wallpaper.timer &
exec i3 exec i3

View file

@ -1,4 +1,8 @@
{config, ...}: { {
config,
pkgs,
...
}: {
programs.streamdeck-ui = { programs.streamdeck-ui = {
enable = true; enable = true;
settings = { settings = {
@ -70,4 +74,18 @@
}; };
}; };
}; };
systemd.user = {
services = {
streamdeck-ui = {
Unit = {
Description = "start streamdeck-ui";
};
Service = {
Type = "exec";
ExecStart = "${pkgs.streamdeck-ui}/bin/streamdeck-ui --no-ui";
};
Install.WantedBy = ["graphical-session.target"];
};
};
};
} }