Hi,

> This doesn't guarantee that the service is run on resume.
> Those targets are activated on suspend/hibernate, so there is a race and
> you might actually run /usr/lib/pm-utils/power.d/95hdparm-apm *before*
> the system is suspended. You'd have to order this service after the
> *service* which does the actual suspend.

Ouch. Thanks for the review.
What does upstream recommend to do?

> Even though upstream recommends against shipping a snippet in
> /lib/systemd/system-sleep/ and considers them hacks, I actually think
> this is the cleanest/simplest solution here
> 
> $ cat /lib/systemd/system-sleep/hdparm
> 
> #!/bin/sh
> 
> case $1 in
>   post)
>     /usr/lib/pm-utils/power.d/95hdparm-apm resume
>     ;;
> esac
> 
> [1] man systemd-sleep

I found the following in the Arch wiki:
<https://wiki.archlinux.org/index.php/Power_management#Suspend.2Fresume_service_files>.
Superficially, that looks very similar to the hdparm service file
proposed above (and I think I remember looking at the Arch Wiki when I
tried to fix hdparm). Essentially, they are suggesting two different
kinds of hooks:

> [Unit]
> Description=Local system resume actions
> After=suspend.target
> 
> [Service]
> Type=simple
> ExecStart=/usr/bin/on-resume
> 
> [Install]
> WantedBy=suspend.target

That looks like it has exactly the same race?

> [Unit]
> Description=Some sleep hook
> Before=sleep.target
> StopWhenUnneeded=yes
> 
> [Service]
> Type=oneshot
> RemainAfterExit=yes
> ExecStart=-/usr/bin/on-suspend
> ExecStop=-/usr/bin/on-resume
> 
> [Install]
> WantedBy=sleep.target

This looks different, but that may be just superficial.

Kind regards,
Ralf


-- 
To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to