Xfce Forum

Sub domains
 

You are not logged in.

#1 2021-03-06 13:40:48

frmald
Member
Registered: 2021-01-02
Posts: 22

Run script at logout (session end)?

Is there a way to hook up a script so that it runs when the session exits? Not necessarily via XFCE, something similar to $HOME/.xsessionrc would do (but I don't believe it exists).

I think GDM has a postsession, but I'd rather stick to lightdm.

Offline

#2 2021-03-06 18:09:03

ctac
Member
Registered: 2017-05-08
Posts: 57

Re: Run script at logout (session end)?

Take a look at session-cleanup-script in lightdm.conf

Offline

#3 2021-03-07 04:15:56

frmald
Member
Registered: 2021-01-02
Posts: 22

Re: Run script at logout (session end)?

Thanks! That was a good hint, but that script is documented as "runs as root", and I'd like to run mine as part of the session.

I ended up removing "exec" from /etc/X11/Xsession.d/99x11-common_start. This allows more scripts to be added after 99x11* in /etc/X11/Xsession.d/ (e.g. 99zzz-user-*). On Debian, `dpkg-divert` can be used to make this survive upgrades.

Of course, this requires admin rights, and it's not a solution for everyone. On systemd systems, one can add systemd --user scripts.

Offline

#4 2021-03-07 18:33:25

ctac
Member
Registered: 2017-05-08
Posts: 57

Re: Run script at logout (session end)?

frmald wrote:

GDM has a postsession

This script is runs as root too.
What do you want to do whithout root privilege?
You can do su -l "SUSER" in this script.

Offline

#5 2021-03-08 18:30:33

frmald
Member
Registered: 2021-01-02
Posts: 22

Re: Run script at logout (session end)?

ctac wrote:

This script is runs as root too.
What do you want to do whithout root privilege?
You can do su -l "SUSER" in this script.

Yeah, I could su (or sudo)... but it wouldn't be part of the session, and I'm not sure what the implications are (presumably no --user dbus / systemd-related commands, which I'm not currently using anyway, but I might want to).

Also, I don't think you can cleanly  find out post-session what the logged in user was.

For the moment, I'm just saving back some cached files from /tmp/... to ~/

Last edited by frmald (2021-03-08 18:31:51)

Offline

#6 2021-03-10 23:38:18

jarnos
Member
From: Finland
Registered: 2009-03-22
Posts: 50
Website

Re: Run script at logout (session end)?

Try to add an item in the Application Autostart tab of Session and Startup dialog. You can choose there when to trigger the command.

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.013 seconds, 7 queries executed - Memory usage: 532.42 KiB (Peak: 533.05 KiB) ]