From a5da3d0924c87715d6bd336a3eafb41e1271532f Mon Sep 17 00:00:00 2001 From: Martin Berg Alstad Date: Sat, 4 Jan 2025 23:06:06 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=A5=20Hypridle=20suspend=20and=20refac?= =?UTF-8?q?tor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- home/hyprland/hypridle/default.nix | 29 ++++++++++++++++++++--------- home/hyprland/hyprland.conf | 5 +++++ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/home/hyprland/hypridle/default.nix b/home/hyprland/hypridle/default.nix index f7a0f1d..b7c5403 100644 --- a/home/hyprland/hypridle/default.nix +++ b/home/hyprland/hypridle/default.nix @@ -1,25 +1,36 @@ { ... }: - +let + # Time in seconds + lockAfter = 1200; + suspendAfter = 7200; +in { services.hypridle = { enable = true; settings = { general = { + before_sleep_cmd = "loginctl lock-session"; after_sleep_cmd = "hyprctl dispatch dpms on"; - ignore_dbus_inhibit = false; lock_cmd = "pidof hyprlock || hyprlock"; # Avoid running multiple instances of hyprlock }; listener = [ + # Lock { - timeout = 900; # 15 min - on-timeout = "hyprlock"; + timeout = lockAfter; + on-timeout = "loginctl lock-session"; + } + # Turn off screens TODO buggy main monitor, turns off and on after resume +# { +# timeout = 120; +# on-timeout = "hyprctl dispatch dpms off"; +# on-resume = "hyprctl dispatch dpms on"; +# } + # Suspend + { + timeout = suspendAfter; + on-timeout = "systemctl suspend"; # suspend pc } - # { - # timeout = 1200; - # on-timeout = "hyprctl dispatch dpms off"; - # on-resume = "hyprctl dispatch dpms on"; - # } ]; }; }; diff --git a/home/hyprland/hyprland.conf b/home/hyprland/hyprland.conf index 8d6f10e..926b850 100644 --- a/home/hyprland/hyprland.conf +++ b/home/hyprland/hyprland.conf @@ -392,3 +392,8 @@ windowrulev2 = suppressevent maximize, class:.* # Fix some dragging issues with XWayland windowrulev2 = nofocus,class:^$,title:^$,xwayland:1,floating:1,fullscreen:0,pinned:0 + +# Avoid locking in fullscreen +windowrulev2 = idleinhibit fullscreen, class:^(*)$ +windowrulev2 = idleinhibit fullscreen, title:^(*)$ +windowrulev2 = idleinhibit fullscreen, fullscreen:1