How can I make a script run automatically after gdm login and logout?

I have a setup where my users log on using ldap and it works just fine.

I want to run a script after my users login (its a script that will detect which groups they are in and map network shares accordingly), and after they logout (umounting their shares).

Both scripts are done and they work.

I want that when the user logs in the box a script runs downloading the mounting script from my server (wget i guess?) and runs it, same thing for logout.

Can it be done? I've been searching the net and had no luck so far. I've managed to make that work on shell login/logout, but my users dont even know what shell is and have no use for it :)


Found it.

/etc/gdm/PostLogin/Default for login script
/etc/gdm/PostSession/Default for logout script

I figured from Florian's suggestion that there should be something for gdm that did it :)


  • Use /etc/X11/Xsession.d and /etc/X11/Xreset.d/

  • Maybe pam_mount (package libpam-mount in Ubuntu) can replace your solution.