I figured it out, in case anyone else would ever like to accomplish this.
With your standard bash shell on a unix system, you would just create a .bash_logout
file in your home directory, and put any commands you want to run on logout in that file. The trouble is that linux mint is not set up to look for .bash_logout
in your home directory, and run it on logout. You can make a quick and painless modification that enables this however. It's the perfect solution, because than any user can create their very own .bash_logout
file in their home directory, and it will automatically run whenever they logout of the system.
So what you want to do is to get linux to execute a .bash_logout
file in $HOME when a user logs out of the system. To do that, you need to modify the /etc/gdm/PostSession/Default
file. This file is run by root whenever a logout occurs. Note that you don't want to just add the line $HOME/.bash_logout
to this file though. Since the /etc/gdm/PostSession/Default
file is run as root on logout, if you just call $HOME/.bash_logout
, you would end up giving every single user root access in their logout file. So all it would take is one user to write a malicious .bash_logout
file, and you could loose your entire operating system.
So here is what you need to put in that file:
- Code: Select all
#Execute logout script for any user
sudo -u $USER $HOME/.bash_logout
This will run the logout script as the correct user, so you don't have to worry about someone creating an evil bash logout file to destroy your system.
So once you do the above, you can make a .bash_logout file in your home directory. Make sure to give it execute permissions! If you don't give it execute permissions, it will never run. Then add any scripts you would like to run on logout, to that configuration file. So make a script to clear the thumbnail cache, and bingo!
As a general precaution, I would definitely stick a command in your .bash_logout
file that prints out to a log somewhere, so that you can verify that your logout file is actually being called on logout. Here is what I have in mine to accomplish that:
- Code: Select all
#Save logout execution to .logout_log
echo `date` Logout Occurred >> .logout_log
If you use the above code in your /etc/gdm/PostSession/Default
file, just check to see if the file .logout_log
appears in your home directory after you log out once. If it does, open it up and it should have the date and time of logout. If it doesn't show up, something is wrong, and your logout configuration isn't working.