How to run a daemon process only when xfce4 session is running?

Chris Green cl at isbd.net
Mon Jan 31 18:09:20 CET 2022


Alexander Schwinn <acs82 at gmx.de> wrote:
> [-- multipart/alternative, encoding 7bit, 82 lines --]
> 
>     [-- text/plain, encoding quoted-printable, charset: utf-8, 43 lines --]
> 
> Hi Chris,
> 
> If you are using systemd, you could make a daemon out of it, and start 
> / stop it via systemctl start/stop. E.g: 
> 
> https://unix.stackexchange.com/questions/426862/proper-way-to-run-shell-script-as-a-daemon
> 
Yes, I have some other things run by systemd but they run from startup
to shutdown, not just during a GUI session.  Does systemd know about X
sessions?


> Though I did not check if that as well works without sudo magic / as a user.
> 
> Another posibility could be to start it with nohup and and kill it via 
> "killall myscript" on logout 
> 
But there's no logout 'hook' is there?  Where would I put this killall
so that it runs when I log out of the xfce4 session?  


> I suppose you saw the hooks to login/logout you can place in xfce4-session-settings 
> / applicatiom-autostart ? 
> 
Er, no, not really.  That's exactly the problem, I have my 'daemon' on
xfce4-session-settings to start 'on login' but there doesn't seem to
be any way to stop it at logout.

-- 
Chris Green
ยท



More information about the Xfce mailing list