I'm trying to write a "system sleep" script for systemd-suspend.service
, to shutdown a user service before suspend (as it blocks suspending the kernel) and restart it after the system resumes.
The problem is that the system sleep script runs with system permissions, and I'm not sure how to address the user service - systemctl --user
obviously doesn't work.
I've tried running su -c "systemctl --user stop <service>" <user>
and USER=<user> systemctl --user stop <service>
but both just get this error:
Failed to connect to bus: No such file or directory
The man page for systemctl
doesn't offer much guidance about this issue.
systemctl
being a Desktop Bus client. – JdeBP Aug 22 '18 at 12:40sudo
. – Guss Aug 23 '18 at 16:08