1
1
Fork 0

hypridle: switch to systemd-lock-handler for lockscreen

Signed-off-by: Myned <dev@bjork.tech>
This commit is contained in:
Myned 2024-12-30 10:08:25 -06:00
parent 16c480c8f6
commit 0ec4890572
Signed by: Myned
GPG key ID: C7224454F7881A34
2 changed files with 27 additions and 39 deletions

View file

@ -36,6 +36,7 @@ in {
rounding = mkOption {default = 15;}; rounding = mkOption {default = 15;};
### Misc ### Misc
lockscreen = mkOption {default = "hyprlock";};
wallpaper = mkOption {default = false;}; wallpaper = mkOption {default = false;};
browser = { browser = {

View file

@ -7,16 +7,25 @@
with lib; let with lib; let
grep = "${pkgs.gnugrep}/bin/grep"; grep = "${pkgs.gnugrep}/bin/grep";
hyprctl = "${config.programs.hyprland.package}/bin/hyprctl"; hyprctl = "${config.programs.hyprland.package}/bin/hyprctl";
hyprlock = "${config.home-manager.users.${config.custom.username}.programs.hyprlock.package}/bin/hyprlock";
loginctl = "${pkgs.systemd}/bin/loginctl"; loginctl = "${pkgs.systemd}/bin/loginctl";
niri = "${config.programs.niri.package}/bin/niri"; niri = "${config.programs.niri.package}/bin/niri";
pgrep = "${pkgs.procps}/bin/pgrep";
pw-cli = "${pkgs.pipewire}/bin/pw-cli"; pw-cli = "${pkgs.pipewire}/bin/pw-cli";
systemctl = "${pkgs.systemd}/bin/systemctl"; systemctl = "${pkgs.systemd}/bin/systemctl";
cfg = config.custom.services.hypridle; cfg = config.custom.services.hypridle;
in { in {
options.custom.services.hypridle.enable = mkOption {default = false;}; options.custom.services.hypridle = {
enable = mkOption {default = false;};
dpms = mkOption {
default =
if config.custom.desktop == "hyprland"
then "${hyprctl} dispatch dpms off"
else if config.custom.desktop == "niri"
then "${niri} msg action power-off-monitors"
else "";
};
};
config.home-manager.users.${config.custom.username} = mkIf cfg.enable { config.home-manager.users.${config.custom.username} = mkIf cfg.enable {
# https://github.com/hyprwm/hypridle # https://github.com/hyprwm/hypridle
@ -24,44 +33,22 @@ in {
services.hypridle = { services.hypridle = {
enable = true; enable = true;
settings = let settings.listener = [
# Workaround for red background immediately showing while lockscreen starts {
# https://github.com/YaLTeR/niri/issues/808 timeout = 15 * 60; # Seconds
do-screen-transition = "${niri} msg action do-screen-transition --delay-ms 1000 &&"; on-timeout = cfg.dpms;
in { }
general = let
lock = "${pgrep} hyprlock || ${
if config.custom.desktops.desktop == "niri"
then do-screen-transition
else ""
} ${hyprlock}";
in {
before_sleep_cmd = "${lock} --immediate";
lock_cmd = lock;
};
listener = [ {
{ timeout = 20 * 60; # Seconds
timeout = 15 * 60; # Seconds on-timeout = "${loginctl} lock-session";
on-timeout = "${loginctl} lock-session"; }
}
{ {
timeout = 20 * 60; # Seconds timeout = 60 * 60; # Seconds
on-timeout = on-timeout = "${pw-cli} info all | ${grep} running || ${systemctl} suspend-then-hibernate"; # Suspend if no audio
if config.custom.desktops.desktop == "hyprland" }
then "${hyprctl} dispatch dpms off" ];
else if config.custom.desktops.desktop == "niri"
then "${niri} msg action power-off-monitors"
else "";
}
{
timeout = 60 * 60; # Seconds
on-timeout = "${pw-cli} info all | ${grep} running || ${systemctl} suspend-then-hibernate"; # Suspend if no audio
}
];
};
}; };
# BUG: graphical-session-pre.target may not have WAYLAND_DISPLAY set, so service is skipped # BUG: graphical-session-pre.target may not have WAYLAND_DISPLAY set, so service is skipped