Thumbnail Caching (Disable / Clear Cache on Logout)

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help

Thumbnail Caching (Disable / Clear Cache on Logout)

Postby KyleFx on Sat Feb 28, 2009 10:18 pm

Hi Everyone,

I'm fairly new to linux, and I've been trying to figure this out, with little success. I see that thumbnail images are cached in the home directory .thumbnails folder. I would like to either be able to disable caching of thumbnails altogether, or simply be able to run a script on logout, that clears the the thumbnail cache. Is something like this possible? Can a script be set to run at logout somehow?

I've gotten as far as making a shell script to remove all thumbnail images. But I don't know how to make it run when I logout. ;) Any input is greatly appreciated.

Thanks,
-Kyle
User avatar
KyleFx
Level 1
Level 1
 
Posts: 10
Joined: Sat Feb 28, 2009 10:06 pm

Linux Mint is funded by ads and donations.
 

Re: Thumbnail Caching (Disable / Clear Cache on Logout)

Postby proxima_centauri on Sat Feb 28, 2009 11:02 pm

Something like this
http://ubuntu.wordpress.com/2006/02/15/ ... humbnails/
or
http://arcticlinux.blogspot.com/2007/10 ... nails.html

Also try going into Nautilus->Edit->Preferences, and changing the thumbnail option under the Preview tab
User avatar
proxima_centauri
Level 11
Level 11
 
Posts: 3976
Joined: Tue Dec 25, 2007 3:24 pm
Location: NB, Canada

Re: Thumbnail Caching (Disable / Clear Cache on Logout)

Postby Fred on Sun Mar 01, 2009 10:14 am

KyleFx,

Does it matter to you whether it runs on boot or shutdown? If not you can call the script from /etc/rc.local on boot.

Fred
Insanity: Doing the same thing over and over and each time expecting a different result.

Democracy is 2 wolves and a lamb voting on the menu. Liberty is an armed lamb protesting the electoral outcome. A Republic negates the need for an armed protest.
User avatar
Fred
Level 10
Level 10
 
Posts: 3356
Joined: Fri Jan 04, 2008 11:59 am
Location: NC USA

Re: Thumbnail Caching (Disable / Clear Cache on Logout)

Postby KyleFx on Sun Mar 01, 2009 10:44 am

Fred wrote:KyleFx,

Does it matter to you whether it runs on boot or shutdown? If not you can call the script from /etc/rc.local on boot.

Fred


Not completely, and that is what I will end up doing if I can't figure out another way. Ideally, I would like to be able to clear the thumbnails on logout. I was hoping for a simple way to run a script on logout, but if that's not possible, I can do it on boot or login. ;)

Or if there is a way to disable thumbnail caching, that would work well also. I wonder what would happen if I took away write permissions to .thumbnails. Do you think that would prevent thumbnail caching? Hmmmm
User avatar
KyleFx
Level 1
Level 1
 
Posts: 10
Joined: Sat Feb 28, 2009 10:06 pm

Re: Thumbnail Caching (Disable / Clear Cache on Logout)

Postby KyleFx on Sun Mar 01, 2009 11:07 am

KyleFx wrote:
I wonder what would happen if I took away write permissions to .thumbnails. Do you think that would prevent thumbnail caching? Hmmmm


Ok, so that disables thumbnail caching, but it also makes the OS slightly angry. :mrgreen:

Basically, once you give write permissions back, the thumbnails for the images you browsed to during the time write permissions were gone, don't show up. I couldn't find a way to get them to refresh, except to copy them somewhere else, and then copy them back. And that worked... but I realize I would much prefer a logout script if at all possible. Is there any way that anyone knows of, to get a scrip to run when a user logs out?

Thanks,
-Kyle
User avatar
KyleFx
Level 1
Level 1
 
Posts: 10
Joined: Sat Feb 28, 2009 10:06 pm

Re: Thumbnail Caching (Disable / Clear Cache on Logout)

Postby KyleFx on Thu Mar 12, 2009 1:07 pm

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. ;)
User avatar
KyleFx
Level 1
Level 1
 
Posts: 10
Joined: Sat Feb 28, 2009 10:06 pm

Re: Thumbnail Caching (Disable / Clear Cache on Logout)

Postby doubleganger on Sun Mar 30, 2014 8:48 am

to disable thumbnail cacheing including image viewers
in the file browser (caja) go to edit/preferences/preview/thumbnails and set to never
then in a terminal window at the command prompt:
cd ~/.cache
mv thumbnails xthumbnails
ln -s thumbnails /dev/null
doubleganger
Level 1
Level 1
 
Posts: 1
Joined: Sun Oct 16, 2011 7:11 am

Linux Mint is funded by ads and donations.
 

Return to Newbie Questions

Who is online

Users browsing this forum: Bing [Bot] and 32 guests