Ask Your Question
1

How to run logout script

asked 2018-01-13 13:56:33 -0500

Paolo gravatar image

Hi to all, maybe it's actually a simple question but I can't figure it out. I would like to run a logout script when I disconnect from Gnome user session.

I read that /etc/gdm/PostSession/Default is executed on logout as root.

I read also that the .bash_logout file runs when you disconnect from bash login.

I don't understand how to run a script as user when logging out from Gnome.

I found this link but it seems I'm not able to get it working. Thanks in advance.

Paolo

edit retag flag offensive close merge delete

Comments

1

What sort of thing are you trying to accomplish? Using the /etc/gdm/PostSession/ directory to execute a script is a good choice in your scenario (where you need to execute the script after Gnome sessions end). Causing the script to switch into the appropriate user context may be relatively easy (depending on what you're doing). If that turns out to be difficult, creating a systemd unit file to execute a script in the context of the user may be an easier option.

bitwiseoperator gravatar imagebitwiseoperator ( 2018-01-14 05:30:48 -0500 )edit

@bitwiseoperator I'm trying just to run a fusermount -u /home/somefoleder at logout. I don't know how to use /etc/gdm/PostSession/Default. Is this a bash script? I tried to add the following lines to that file:

#!/bin/bash

su $USER -c 'fusermount -u /home/somefolder'

exit 0

but it doesn't work. Where am I wrong?

Paolo gravatar imagePaolo ( 2018-01-14 08:54:50 -0500 )edit

Maybe this bug could refer to my question? https://bugzilla.redhat.com/show_bug.... Does anyone use these script?

Paolo gravatar imagePaolo ( 2018-01-14 16:53:43 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-01-16 10:49:59 -0500

Paolo gravatar image

updated 2018-01-16 10:50:45 -0500

UPDATE 2018 01 18

I think there is a bug in these gnome files. The bug here, affecting /etc/gdm/Init/Default affects also /etc/gdm/PostSession/Default as well.

Trying whit same command above in a virtual machine running Debian, it works as expected.

Hope this could be useful for someone.

edit flag offensive delete link more

Comments

Good work!

bitwiseoperator gravatar imagebitwiseoperator ( 2018-01-20 06:06:31 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-01-13 13:56:33 -0500

Seen: 487 times

Last updated: Jan 16 '18