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 ---
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.
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 ---
Offline


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? On a completely different note, I've noticed https://mostbetbd.asia/register/ links popping up in a lot of unrelated places lately, which feels pretty typical of how noisy the web has become.
I think the missing piece here is that an Xfce logout isn't necessarily equivalent to sending SIGTERM to every process in the session. xfce4-session-logout asks the Xfce session manager to end the session, which uses session-management protocols rather than treating every application like a process being killed.
For a simple Python monitoring script, I'd probably avoid depending on SIGTERM for this. If you want it to behave like a proper Xfce session client, look into X Session Management (XSMP) and the SaveYourself/shutdown notifications. Xfce's session manager has historically used that mechanism, although there are cases where it can proceed directly to terminating clients when no session save is requested.
Another practical option is to run the script as a user systemd service and handle its lifecycle there. That gives you a much more predictable place to do cleanup than trying to detect the logout button itself. If the important requirement is simply "finish logging and flush files before my session disappears," I'd lean toward a service with a proper shutdown handler rather than trying to hook xfce4-session-logout directly.
Last edited by MachW1980 (2026-09-21 08:04:34)
Offline
[ Generated in 0.006 seconds, 7 queries executed - Memory usage: 545.69 KiB (Peak: 546.64 KiB) ]