2024-04-07 22:16:33 -04:00
{
pkgs ,
lib ,
config ,
2024-04-21 11:03:24 -04:00
osConfig ,
2024-04-07 22:16:33 -04:00
. . .
} : {
2024-03-30 13:58:07 -04:00
options = {
2024-04-17 22:39:00 -04:00
alyraffauf . desktop . hyprland . hypridle . enable =
2024-04-20 13:00:28 -04:00
lib . mkEnableOption " E n a b l e h y p r i d l e . " ;
2024-03-30 13:58:07 -04:00
} ;
2024-04-17 22:39:00 -04:00
config = lib . mkIf config . alyraffauf . desktop . hyprland . hypridle . enable {
2024-03-30 13:58:07 -04:00
# Packages that should be installed to the user profile.
2024-04-20 13:00:28 -04:00
home . packages = with pkgs ; [ hypridle ] ;
2024-03-30 13:58:07 -04:00
2024-04-01 00:27:23 -04:00
xdg . configFile . " h y p r / h y p r i d l e . c o n f " . text = ''
general {
lock_cmd = pidof hyprlock || $ { pkgs . hyprlock } /bin/hyprlock # avoid starting multiple hyprlock instances.
before_sleep_cmd = $ { pkgs . systemd } /bin/loginctl lock-session # lock before suspend.
2024-04-24 18:35:22 -04:00
after_sleep_cmd = $ { config . wayland . windowManager . hyprland . package } /bin/hyprctl dispatch dpms on # to avoid having to press a key twice to turn on the display.
2024-04-01 00:27:23 -04:00
}
listener {
2024-04-18 12:49:35 -04:00
timeout = 300 # 5min.
2024-04-01 00:27:23 -04:00
on-timeout = $ { pkgs . brightnessctl } /bin/brightnessctl - s set 10 # set monitor backlight to minimum, avoid 0 on OLED monitor.
on-resume = $ { pkgs . brightnessctl } /bin/brightnessctl - r # monitor backlight restor.
}
# turn off keyboard backlight, uncomment this section if have keyboard backlight.
2024-04-07 22:16:33 -04:00
#listener {
2024-04-01 00:27:23 -04:00
# timeout = 150 # 2.5min.
# on-timeout = ${pkgs.brightnessctl}/bin/brightnessctl -sd rgb:kbd_backlight set 0 # turn off keyboard backlight.
# on-resume = ${pkgs.brightnessctl}/bin/brightnessctl -rd rgb:kbd_backlight # turn on keyboard backlight.
#}
listener {
timeout = 300 # 5min
on-timeout = $ { pkgs . systemd } /bin/loginctl lock-session # lock screen when timeout has passed
}
listener {
2024-04-20 13:00:28 -04:00
timeout = 330 # 5.5min
2024-04-24 18:35:22 -04:00
on-timeout = $ { config . wayland . windowManager . hyprland . package } /bin/hyprctl dispatch dpms off # screen off when timeout has passed
on-resume = $ { config . wayland . windowManager . hyprland . package } /bin/hyprctl dispatch dpms on # screen on when activity is detected after timeout has fired.
2024-04-01 00:27:23 -04:00
}
listener {
timeout = 900 # 15min
2024-04-21 11:03:24 -04:00
on-timeout = $ { if osConfig . networking . hostName == " m a u v i l l e " then " " else " ${ pkgs . systemd } / b i n / s y s t e m c t l s u s p e n d " } # suspend pc unless on mauville
2024-04-01 00:27:23 -04:00
}
'' ;
2024-03-30 13:58:07 -04:00
} ;
}