Re: run a script at the end of a user session

Have a look at /etc/X11/gdm/PostSession
In this script, the user is referenced in the env. var. $USER.
You commonly find stuff like:
    /usr/bin/X11/sessreg -d -w /var/log/wtmp -u /var/run/utmp -l
Just use something like:
    su -c <your_command_or_shell_script> $USER
    su - -c <your_command_or_shell_script> $USER
for a login shell

Andrew Sullivan wrote:

> Hi,
> I asked about this on IRC today, and got a correct answer to the
> question I actually asked.  I wasn't clear enough, though, so I'll
> try again.
> What I want to be able to do is execute a script as the user when
> that user's session ends.  This is analogous to the .logout file in
> bash or the ExitFunction-type commands in many window managers.
> I have a user who wants to move her .forward file out of the way when
> she logs in, and move it back into place when she logs out.  Because
> she's not getting a login shell, the .logout file doesn't get read at
> exit.
> I figure there's got to be a way, since gnome sessions are managed.
> The system in question is using gdm, but I don't see any way to make
> user-specific changes using it (since the PostSession stuff would run
> anything as root, I think it's too dangerous to use).  I figured that
> the logout confirmation is the trick, but I can't tell how I can
> configure that or whether it has any hooks to allow me to run another
> script.
> Any help much appreciated.
> --
> Andrew Sullivan                       |     McMaster University
> Research Computing Support, CIS       |   1280 Main Street West
> ajs keynes cis mcmaster ca            |       Hamilton, Ontario
> +1 905 525 9140 x 27601               |                 L8S 4L8
> _______________________________________________
> gnome-list mailing list
> gnome-list gnome org

                                     Remi Cohen-Scali
   _/_/_/   _/    _/  _/      /      Development engineer
   _/      _/    _/  _/_/   _/       International Center for Network Computing
  _/_/_/  _/    _/  _/  _/ _/        Network Service Provider Division
     _/  _/    _/  _/   _/_/         Phone:     +33-139-447-509  x44509
_/_/_/   _/_/_/   _/     _/          E-mails: Remi Cohen-Scali Sun COM
M  I  C  R  O  S  Y  S  T  E  M  S            Remi Cohen-Scali COM
                                     WAPmail: Remi CohenScali Itineris Net

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]