Lennart Poettering <lenn...@poettering.net> writes: > On Fri, 25.09.15 22:17, Łukasz Stelmach (stl...@poczta.fm) wrote: > >> 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? > > Applications should use suspend delay inhibitors in logind so that > they get a certain amount of time to whatever they want to do before > the system goes to sleep. > > https://wiki.freedesktop.org/www/Software/systemd/inhibit/
Of course a process like NetworkManager or LibreOffice that are running regardless of power state changes and need a finite amount of time to prepare to sleep will use inhibitors. What about oneshot jobs that do not run before the system goes to sleep and simply exit when they are ready? Then again, inhibitors or rather PrepareFor*(false) signals provide no reliable way to know that a machine has just woke up. The signals are emmited in case of failed shutdown too. How can I run something upon resume? Is there no other way than hacky StopWhenUnneeded+ExecStop+WantedBy=sleep.target? OK. I can start on suspend and wait for PrepareForSuspend(false) and check if certain amount of time has passed. Still, it's much too much for some simple oneshot tasks which should do their job while being managed by a process manager (systemd?). >> Then, does any part of systemd (package) react to plugging and >> unplugging DC jack into a laptop? > > I think you get an uevent for this, hence you could do it via udev > rules, no? Indeed. I must have forgotten about this because saw my EeePC trying to report this as input events too. Kind regards, -- Było mi bardzo miło. --- Rurku. --- ... >Łukasz< --- To dobrze, że mnie słuchasz.
pgp61ofmTrlTX.pgp
Description: PGP signature
_______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel