From 47043046d0ce9e1f5d3a45dac4412aa76fcd4efc Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Thu, 15 Feb 2024 16:42:32 +0100 Subject: [PATCH] move onresume and onsuspend scripts to powerManagement --- hosts/niks/configuration.nix | 52 ++++++++---------------------------- 1 file changed, 11 insertions(+), 41 deletions(-) diff --git a/hosts/niks/configuration.nix b/hosts/niks/configuration.nix index 1ad3fb6..5d553ee 100644 --- a/hosts/niks/configuration.nix +++ b/hosts/niks/configuration.nix @@ -274,47 +274,17 @@ ]; }; - systemd.services = { - "suspend@" = { - description = "Unit suspend actions"; - before = [ "sleep.target" ]; - - serviceConfig = { - User = "%I"; - Type = "forking"; - }; - - environment = { - DISPLAY = ":0"; - }; - - preStart = "${pkgs.mpc-cli}/bin/mpc pause"; - script = "${inputs.nixpkgs-wayland.packages.${pkgs.system}.swaylock-effects}/bin/swaylock"; - postStart = "${pkgs.coreutils-full}/bin/sleep 1"; - - wantedBy = [ "sleep.target" ]; - }; - - "resume@" = { - description = "Unit resume actions"; - after = [ "suspend.target" ]; - - serviceConfig = { - User = "%I"; - Type = "forking"; - }; - - environment = { - DISPLAY = ":0"; - }; - - script = '' - ${inputs.hyprland.packages.${pkgs.system}.hyprland}/bin/hyprctl dispatch dpms off HDMI-A-1 - ${inputs.hyprland.packages.${pkgs.system}.hyprland}/bin/hyprctl dispatch dpms on HDMI-A-1 - ''; - - wantedBy = [ "sleep.target" ]; - }; + powerManagement = { + enable = true; + powerDownCommands = '' + ${pkgs.mpc-cli}/bin/mpc pause + ${inputs.nixpkgs-wayland.packages.${pkgs.system}.swaylock-effects}/bin/swaylock + ${pkgs.coreutils-full}/bin/sleep 1 + ''; + powerUpCommands = '' + ${inputs.hyprland.packages.${pkgs.system}.hyprland}/bin/hyprctl dispatch dpms off HDMI-A-1 + ${inputs.hyprland.packages.${pkgs.system}.hyprland}/bin/hyprctl dispatch dpms on HDMI-A-1 + ''; }; # this makes usb devices autosuspend