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,
minimal,
config,
...
}:
lib.optionalAttrs (!minimal) {
@ -26,4 +28,21 @@ lib.optionalAttrs (!minimal) {
};
};
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 =
pkgs.writeShellScript "set-wallpaper"
''
if [ -d "/tmp/.X11-unix" ]; then
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
${pkgs.feh}/bin/feh --no-fehbg --bg-fill --randomize --recursive ${wallpaper-folder}/
'';
in {
systemd.user = {
@ -22,7 +17,6 @@ in {
Description = "Set a random wallpaper every 3 minutes";
};
Timer = {
OnActiveSec = "2 sec";
OnUnitActiveSec = "3 min";
};
Install.WantedBy = ["timers.target"];
@ -38,6 +32,7 @@ in {
ExecStart =
exe;
};
Install.WantedBy = ["graphical-session.target"];
};
};
};

View file

@ -4,11 +4,6 @@
#
# 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
# https://nixos.wiki/wiki/Using_X_without_a_Display_Manager
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
fi
autorandr -c
streamdeck --no-ui &
systemctl --user start set-wallpaper.timer &
exec i3

View file

@ -1,4 +1,8 @@
{config, ...}: {
{
config,
pkgs,
...
}: {
programs.streamdeck-ui = {
enable = true;
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"];
};
};
};
}