[systemd-devel] suspend/resume hooks, the right way

Łukasz Stelmach stlman at poczta.fm
Fri Sep 25 13:17:08 PDT 2015


Hi,

systemd-sleep(8) states

       Note that scripts or binaries dropped in /usr/lib/systemd/system-sleep/
       are intended for local use only and should be considered hacks. If
       applications want to be notified of system suspend/hibernation and
       resume, there are much nicer interfaces available.

What is the right way to hook some oneshot services like battery status
monitor[1] into systemd so they get executed as pre-sleep and
post-resume (or more specifically (pre|post)-(suspend|hibernate|hybrid-sleep)
if possible) hooks? I found some notes[2] on Arch wiki. Unfortunately
the unit with both StopWhenUnneeded and RemainAfterExit does not work
well when triggered with timer because it executes both ExecStart and
ExecStop commands and puts duplicate entries in the log.

Then, does any part of systemd (package) react to plugging and
unplugging DC jack into a laptop?

[1] http://people.skolelinux.org/pere/blog/The_life_and_death_of_a_laptop_battery.html
[2] https://wiki.archlinux.org/index.php/Power_management#Sleep_hooks
-- 
Było mi bardzo miło.                                  --- Rurku. --- ...
>Łukasz<                                --- To dobrze, że mnie słuchasz.


More information about the systemd-devel mailing list