Talk:Uswsusp

From ArchWiki
Jump to: navigation, search

Systemd integration

I believe the systemd integration is not thought out very well. I'll describe what I think should be there. An even better solution would be to rewrite uswsusp, but I have zero interest in that.

Disclaimer: I didn't test it, but in theory this configuration is sound.

  • Create this executable script
/usr/local/lib/systemd-uswsusp.sh
#!/bin/sh
[ x"$1" = x"hibernate" -o x"$1" = x"hybrid-sleep"] || exit 1
/usr/bin/run-parts --regex .\* -a pre -a "$1" -- /usr/lib/systemd/system-sleep
if [ x"$1" = x"hibernate" ]; then
    /usr/bin/s2disk
else
    /usr/bin/s2both
fi
result=$?
# always run post scripts in order to possibly restore settings altered in pre script.
/usr/bin/run-parts --regex .\*  --reverse -a post -a "$1" -- /usr/lib/systemd/system-sleep
exit $result
  • Create these files with all missing directories:
/etc/systemd/system/systemd-hibernate.service.d/uswsusp.conf
[Service]
ExecStart=
ExecStart=/usr/local/lib/systemd-uswsusp.sh hibernate
/etc/systemd/system/systemd-hybrid-sleep.service.d/uswsusp.conf
[Service]
ExecStart=
ExecStart=/usr/local/lib/systemd-uswsusp.sh hybrid-sleep