Executing a script when the user logins from the command line, is an easy task. But I needed to execute a script when the users logs in or out, on the Gnome Device Manager (GDM), the gnome login window from startup.
After some googling I found a solution satisfying my needs.
To make a script execute when the users logs in or logs out on the GDM screen, do this:
Make sure that your scripts have x rights. If they don’t have execution rights, add the x bit with chmod:
$ sudo chmod +x /path/to/scripts/sample_script_one.sh
$ sudo chmod +x /path/to/scripts/sample_script_two.sh
Make the scripts exec at gdm login or logout:
To make a script exec at the gdm login, append, as root ./path/to/script to /etc/gdm/PostLogin/Default:
$ sudo su
# echo "./path/to/scripts/sample_script_one.sh" >> /etc/gdm/PostLogin/Default
To make a script exec at the gdm logout, append, as root ./path/to/script to /etc/gdm/PostSession/Default:
$ sudo su
# echo "./path/to/scripts/sample_script_two.sh" >> /etc/gdm/PostSession/Default