From d860f9f78e93952dbd1a5a86692a515b1894eaf0 Mon Sep 17 00:00:00 2001 From: Mathijs Kwik Date: Sat, 24 Aug 2013 17:47:06 +0200 Subject: [PATCH] power management: provide a post-resume target and unify suspend/hibernate/hybrid-sleep handling --- modules/config/power-management.nix | 30 +++++++++++------------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/modules/config/power-management.nix b/modules/config/power-management.nix index 50c7482a372..2a0874c929d 100644 --- a/modules/config/power-management.nix +++ b/modules/config/power-management.nix @@ -72,6 +72,14 @@ in powerManagement.cpuFreqGovernor = mkDefault "ondemand"; powerManagement.scsiLinkPolicy = mkDefault "min_power"; + systemd.targets.post-resume = { + description = "This target is reached after a hibernate/suspend/hybrid-sleep has woken up."; + requires = [ "post-resume.service" ]; + after = [ "post-resume.service" ]; + wantedBy = [ "sleep.target" ]; + unitConfig.StopWhenUnneeded = true; + }; + # Service executed before suspending/hibernating. systemd.services."pre-sleep" = { description = "Pre-Sleep Actions"; @@ -84,25 +92,9 @@ in serviceConfig.Type = "oneshot"; }; - # Service executed before suspending/hibernating. There doesn't - # seem to be a good way to hook in a service to be executed after - # both suspend *and* hibernate, so have a separate one for each. - systemd.services."post-suspend" = - { description = "Post-Suspend Actions"; - wantedBy = [ "suspend.target" ]; - after = [ "systemd-suspend.service" ]; - script = - '' - ${cfg.resumeCommands} - ${cfg.powerUpCommands} - ''; - serviceConfig.Type = "oneshot"; - }; - - systemd.services."post-hibernate" = - { description = "Post-Hibernate Actions"; - wantedBy = [ "hibernate.target" ]; - after = [ "systemd-hibernate.service" ]; + systemd.services."post-resume" = + { description = "Post-Resume Actions"; + after = [ "suspend.target" "hibernate.target" "hybrid-sleep.target" ]; script = '' ${cfg.resumeCommands}