[systemd-devel] suspend hook as user service
Michael Hirmke
mh at mike.franken.de
Sat Feb 18 14:48:00 UTC 2017
Hi,
>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:
uhm, I understood that you just wanted to have something executed in the
context of a given user. And for this purpose the solution I described
works in most cases.
>systemctl --user enable myservice.service
Never tried that, because in the first implementations it didn't work
reliably. But what about my second suggestion regarding a script
listening to the loginmanager signals?
If you are familiar with perl, I could give you my script to adapt it as
you need.
>R.H.
Bye.
Michael.
>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
--
Michael Hirmke
More information about the systemd-devel
mailing list