2016-03-18 17:16 GMT+01:00 Cecil Westerhof <[email protected]>:

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

​For what it is worth: normally ‘systemctl​

​suspend’ returns 1, but from the systemd service it returns 4.​



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



-- 
Cecil Westerhof
_______________________________________________
systemd-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to