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

Andrei Borzenkov arvidjaar at gmail.com
Fri Sep 25 23:48:55 PDT 2015


25.09.2015 23:17, Łukasz Stelmach пишет:
> 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?

This one looks pretty fine as system-sleep hook. What's wrong with it?

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



More information about the systemd-devel mailing list