From dc57acb9d83a85215ca81b4171e49309f90d2967 Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Wed, 26 Feb 2025 22:06:03 +0100 Subject: [PATCH] Let hypridle handle screen lock before suspend --- modules/home/de/hypridle.nix | 4 ++-- modules/home/de/hyprland/keybinds.nix | 7 ++++--- modules/home/hibernate.nix | 4 ++++ modules/system/geoclue.nix | 2 +- users/seb/@inspiron/home.nix | 8 +------- users/seb/@north/home.nix | 6 +++++- 6 files changed, 17 insertions(+), 14 deletions(-) create mode 100644 modules/home/hibernate.nix diff --git a/modules/home/de/hypridle.nix b/modules/home/de/hypridle.nix index e02a187..e0949f6 100644 --- a/modules/home/de/hypridle.nix +++ b/modules/home/de/hypridle.nix @@ -12,7 +12,6 @@ home.packages = [ wrappers.hyprlock pkgs.brightnessctl - (pkgs.writeScriptBin "lock-suspend" "loginctl lock-session && sleep 0.5 && systemctl suspend-then-hibernate") ]; services.hypridle = { @@ -21,6 +20,7 @@ settings = { general = { lock_cmd = "pidof hyprlock || hyprlock"; + before_sleep_cmd = "loginctl lock-session"; after_sleep_cmd = "hyprctl dispatch dpms on"; }; @@ -41,7 +41,7 @@ } { timeout = 1800; - on-timeout = "lock-suspend"; + on-timeout = "systemctl suspend${lib.optionalString config.myConfig.hibernation.enable "-then-hibernate"}"; } ]; }; diff --git a/modules/home/de/hyprland/keybinds.nix b/modules/home/de/hyprland/keybinds.nix index 1542872..c989c99 100644 --- a/modules/home/de/hyprland/keybinds.nix +++ b/modules/home/de/hyprland/keybinds.nix @@ -8,6 +8,7 @@ # l = locked # Variables + $suspend = systemctl suspend${lib.optionalString config.myConfig.hibernation.enable "-then-hibernate"} $play-pause = playerctl --ignore-player=firefox play-pause $play-next = playerctl --ignore-player=firefox next $play-previous = playerctl --ignore-player=firefox previous @@ -61,9 +62,9 @@ bindrl = SUPER CONTROL, Q, exit, bindrl = SUPER CONTROL, P, exec, poweroff bindrl = SUPER CONTROL, R, exec, reboot - bindrl = SUPER CONTROL, H, exec, systemctl hibernate - bindrl = SUPER CONTROL, S, exec, lock-suspend - bindl = , switch:on:Lid Switch, exec, lock-suspend + ${lib.optionalString config.myConfig.hibernation.enable "bindrl = SUPER CONTROL, H, exec, systemctl hibernate"} + bindrl = SUPER CONTROL, S, exec, $suspend + bindl = , switch:on:Lid Switch, exec, $suspend bindrl = SUPER CONTROL, L, exec, loginctl lock-session bindrl = SUPER CONTROL, B, exec, sleep 1 && hyprctl dispatch dpms off diff --git a/modules/home/hibernate.nix b/modules/home/hibernate.nix new file mode 100644 index 0000000..1a0a720 --- /dev/null +++ b/modules/home/hibernate.nix @@ -0,0 +1,4 @@ +{ lib, ... }: +{ + options.myConfig.hibernation.enable = lib.mkEnableOption ""; +} diff --git a/modules/system/geoclue.nix b/modules/system/geoclue.nix index bf71d90..f2ca748 100644 --- a/modules/system/geoclue.nix +++ b/modules/system/geoclue.nix @@ -6,7 +6,7 @@ services.geoclue2 = { enable = true; geoProviderUrl = "https://beacondb.net/v1/geolocate"; - + appConfig.gammastep = { isAllowed = true; isSystem = false; diff --git a/users/seb/@inspiron/home.nix b/users/seb/@inspiron/home.nix index 8b07e11..9bdccc8 100644 --- a/users/seb/@inspiron/home.nix +++ b/users/seb/@inspiron/home.nix @@ -1,18 +1,12 @@ -{ pkgs, lib, ... }: { imports = [ ../home.nix ]; home.stateVersion = "23.11"; + myConfig.de.theme = "light"; wayland.windowManager.hyprland.settings.monitor = [ "eDP-1,1920x1080@60,0x0,1" ",preferred,auto,1,mirror,eDP-1" ]; - - home.packages = [ - (lib.hiPrio ( - pkgs.writeScriptBin "lock-suspend" "loginctl lock-session && sleep 0.5 && systemctl suspend" - )) - ]; } diff --git a/users/seb/@north/home.nix b/users/seb/@north/home.nix index 9b3f1ee..b2463ae 100644 --- a/users/seb/@north/home.nix +++ b/users/seb/@north/home.nix @@ -3,7 +3,11 @@ imports = [ ../home.nix ]; home.stateVersion = "23.11"; - myConfig.de.theme = "dark"; + + myConfig = { + de.theme = "dark"; + hibernation.enable = true; + }; home.packages = [ pkgs.ffmpeg