[systemd-devel] Suspend does not work from a service
Cecil Westerhof
cldwesterhof at gmail.com
Fri Mar 18 16:16:58 UTC 2016
I wrote as script to put my netbook into suspend when it is locked for five
minutes and not connected to the AC adapter:
https://github.com/CecilWesterhof/BashLibrary/blob/master/bin/suspend.sh
This works perfect when I start it from the command-line, but not when I
use it as a systemd service. Then I get:
Failed to start suspend.target: Access denied
when the
systemctl suspend || true
is executed.
What could be happening here? And how do I solve it?
My service file:
[Unit]
Description=Suspend machine when locked and no AC adaptor
[Service]
Type=simple
ExecStart=/usr/local/bash/bin/suspend.sh
Restart=always
User=cecil
[Install]
WantedBy=multi-user.target
On a related note: why does:
systemctl suspend
give an exit status of 1?
And why does it returns immediately? I had to add a sleep 5 to my script to
make it work.
--
Cecil Westerhof
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20160318/7df33988/attachment.html>
More information about the systemd-devel
mailing list