move onresume and onsuspend scripts to powerManagement

This commit is contained in:
jacekpoz 2024-02-15 16:42:32 +01:00
parent d869f576f7
commit 47043046d0
No known key found for this signature in database
GPG key ID: 94E812A8B12AAE3C

View file

@ -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