[systemd-devel] Help writing a user service file that will exec a command upon system sleep
Simon McVittie
simon.mcvittie at collabora.co.uk
Thu Oct 29 12:27:44 PDT 2015
On 29/10/15 18:52, John wrote:
> This is an interesting idea but I would like to learn about user units and sleep mode :)
I think the intention is that per-user code deals with sleep by having a
service (daemon) that registers to inhibit suspend; when it is notified
that systemd would like to suspend, it does what it needs to do, then
releases the inhibit to allow suspend to continue.
Here's a working implementation (it also handles two flavours of network
connectivity, but you can ignore those bits), which Telepathy uses to
try to log out from IM services before suspending:
http://cgit.freedesktop.org/telepathy/telepathy-mission-control/tree/src/connectivity-monitor.c
--
Simon McVittie
Collabora Ltd. <http://www.collabora.com/>
More information about the systemd-devel
mailing list