You are not logged in.


Linux Mint 22.1 XFCE 4.18
I have a Python script that I launch at login to perform some monitoring and logging tasks during the session.
I want it to be able to shut down gracefully when I log out.
I assumed it would be sent a SIGTERM signal at logout, so I wrote the shut down function to be run when the SIGTERM signal is received.
It works perfectly if I run the python script in a terminal and send the SIGTERM signal via a kill command, but a SIGTERM signal is never received when I log out. Presumably xfce4-session-logout does not send signals.
Is there some way to detect when xfce4-session-logout is about to end the session?
Offline


If you go to Settings Manager > Session and Startup > Application Autostart, you can set a script to run on a logout, restart, or shutdown trigger. You can try that to see if it works.
Otherwise, you can look at creating an xfce4-session wrapper script.
Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Online


If you go to Settings Manager > Session and Startup > Application Autostart, you can set a script to run on a logout, restart, or shutdown trigger. You can try that to see if it works.
Otherwise, you can look at creating an xfce4-session wrapper script.
Thanks for the speedy reply
It looks like the easiest solution is to modify my python script to check for script arguments at launch, and simply re-launch the script with, for example, a '--shutdown' argument via the triggers you mentioned.
Do you know if there is any reliable way to detect a logout/shutdown process programmatically in XFCE, such as via dbus?
Offline


If you put your script in the autostart list, logging out or shutting down will kill the script.
But it's all right, when you're all in pain and you feel the rain come down
It's alright, when you find your way, then you see it disappear
It's alright....
Chris Cornell
Offline


Do you know if there is any reliable way to detect a logout/shutdown process programmatically in XFCE, such as via dbus?
You could try using systemd to run a script on shutdown. See https://forum.manjaro.org/t/running-a-s … /143440/2\ for an example of how this can be done.
Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Online
[ Generated in 0.019 seconds, 7 queries executed - Memory usage: 537.01 KiB (Peak: 537.98 KiB) ]