diff --git a/hosts/niks/configuration.nix b/hosts/niks/configuration.nix index 1ad3fb6aa..5d553ee16 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