[systemd-devel] suspend hook as user service

Reverend Homer mk.43.ecko at gmail.com
Sat Feb 18 13:08:11 UTC 2017


Hi Michael,

thank you for feedback, but you described *system* service and this is the way
I solved my issue for now. The original message was about *user* service — the
service that you can put at $HOME/.config/systemd/user and activate with:

systemctl --user enable myservice.service

R.H.

On Fri, Feb 17, 2017 at 07:41:00PM +0100, Michael Hirmke wrote:
> Hi,
> 
> >Hi,
> 
> >is there any way to start user service before/after suspend.target? In
> >wiki.archlinux.org there are only system sleep hooks [1]. I tried to lock the
> 
> yes, but they also describe, how you can add a system service handling
> special user things.
> 
> [...]
> 
> You can create a service named for example "suspend_user at .service":
> 
> ------------------------< snip snip snip >-----------------------------
> [Unit]
> Description=User suspend actions for KDE
> After=sleep.target remote-fs.target
> Requires=remote-fs.target
> StopWhenUnneeded=yes
> 
> [Service]
> User=%I
> Type=oneshot
> ExecStart=...
> TimeoutSec=300
> 
> [Install]
> WantedBy=sleep.target
> ------------------------< snip snip snip >-----------------------------
> 
> And enable it with:
> systemctl enable suspend_user@<user>.service.
> 
> It worked for me for a while.
> 
> A much better approach is to write a script or program listening for the
> according signals "PrepareForSleep" and "PrepareForShutdown" on the dbus
> interface "org.freedesktop.login1".
> You can start it for example in your .bashrc or in the KDE startup
> routines.
> 
> 
> >R.H.
> 
> Bye.
> Michael.
> -- 
> Michael Hirmke
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel


More information about the systemd-devel mailing list