Skip navigation.

Stephen O'Sullivan

Blah, blah, blah ....

Album art as folder icon in Gnome

, , , ,

One of the rare advantages I find in Windows XP (strangely lost in Vista...) over Linux is the "Thumbnail View" option in Explorer, which replaces icons with thumbnail images. The Gnome desktop natively shows thumbnails of all images and films without the need to change view, as in XP, but the one advantage XP has over Gnome is that it also shows a thumbnail of the folder. With an image called folder.jpg in it, the folder thumbnail shows that image. This is not overly useful in most circumstances, but is excellent for viewing music albums.

It is possible in Gnome to change the icon of an individual folder to an image quite simply in properties, but with thousands of albums, that seemed like work...

NOTE: for Ubuntu 9.10 Karmic, see updated post here

However, I have found a very simple solution here. Ubuntu user fifo has created a very simple python script which you can download from the first link, above. The script basically automates the process of converting a folder icon to, by default, an image in that folder by the name of either folder.jpg or Folder.jpg.

To run the script, navigate to folder you have saved it to (in the terminal, e.g. "cd Desktop"), and type:

$ python custom_icon.py -R /folder/folder (replacing "folder" for the directory you want to convert)

The option -R means that not only the folder you enter, but all its subfolders will be converted.

To refresh Nautilus:

$ nautilus -q



An excellent and simple solution.

UPDATE:

The script as written assumes all the folder images are .jpg in lower case, but if some of your images are .Jpg or .JPG, then simply change the line:

default="[Ff]older.jpg",

to

default="[Ff]older.[Jj][Pp][Gg]",

This script can be downloaded here (all credit to fifo for writing this, I just added the default="[Ff]older.[Jj][Pp][Gg]", line...)

UPDATE 2:

This script does not work in Karmic Koala, but I have recently found a Cover Thumbnailer here that seems to work perfectly. Installation was via a .deb file, so could not have been simpler. I logged out and back in, and it worked. For music albums it adds a cd jewel case frame. For pictures and photographs it adds a photo album frame. I presume it uses the directory tree to ascertain which to use. All other folders with folder.jpg in them get a simple frame with a flip fold on the bottom left.

Below is a picture of the Music folder:

MintMenu in Ubuntu FeistySongbird - best iPod manager for Linux

Comments

ozmargot 21. March 2008, 14:30

I was looking for a way to refresh nautilus after some changes via gconf-editor and .... surprise, Google points to the answer on my.opera. Thanks !

sjosul 31. March 2008, 06:37

My pleasure - it certainly beats logging off and on...

cirrusminora 14. January 2009, 09:46

I was really missing this feature in ubuntu too.Thanks for the post. But a problem lingers.When I refresh nautilus,all my desktop items just disappear.Everything else works fine.I can access the items in the Desktop folder.And once I restart my laptop,its back to normal.I'm puzzled,suitably,for a beginner.Can you advise?

sjosul 16. January 2009, 09:07

Yes, the refresh doesn't redraw nautilus desktop - to be honest, I'm not sure why, but logging out or restarting fixes it as you said. I find that I only update my folder images rarely (for just a few, I do it manually by right-clicking on the folder, choosing properties and then clicking on the folder image on the left hand side...)

Anonymous 1. July 2009, 16:02

Tony writes:

Ah, excellent script. Been looking for just such a simple solution. Thank you.

sjosul 2. July 2009, 04:10

Glad it helped Tony

Anonymous 13. July 2009, 21:50

uskomaton writes:

Oh that is such a nice piece of code.
Thanks a bunch.

Anonymous 16. September 2009, 13:05

Anonymous writes:

thanks for this :)

Anonymous 5. October 2009, 14:17

kaeltas writes:

thx man i love this trick!

Anonymous 9. October 2009, 14:12

rame20002007 writes:

Thanks for this awesome tip. Searching for this for a while.

Anonymous 12. October 2009, 21:21

granjerox writes:

Hi i've just found your script and doesn't work anymore in Ubuntu 9.10 Karmic. Aparently works fine, it makes the xml file but no changes are shown after restarting nautilus.

Do you know why?

granjerox [en] gmail [punto] com

sjosul 13. October 2009, 22:33

I'm still using Jaunty, so haven't experienced the issue. I'll check it out soon and post an update. I assume there have been changes to the Nautilus thumbnail setup.

Anonymous 1. November 2009, 02:19

qos writes:

For all the guys who want to use this in karmic. The old script wont work any longer.

Try me adapted version:
#!/usr/bin/python

import sys
from optparse import OptionParser
import os
import fnmatch
from urllib import quote

def main():
parser = OptionParser(usage="usage: %prog [options] folder [folder2 ...]",
version="%prog 0.1")
parser.add_option("", "--names", dest="names",
default="[Ff]older.[Jj][Pp][Gg]",
help='specification to match image filenames [default: "%default"]')
parser.add_option("-R", "--recursive", dest="recursive", action="store_true", default=False,
help="set icons for folders recursively")

(options, folders) = parser.parse_args(sys.argv)
folders = folders[1:]

if not folders:
parser.error("no folders specified")

noquote = "()'*"

for folder in folders:
for root, dirs, files in os.walk(folder):
print root, "..."
subdirs = []
for d in dirs:
images = fnmatch.filter(os.listdir(os.path.join(root, d)), options.names)
if images:
path = os.path.join(root, d)
image = os.path.basename(images[0])
os.system('gvfs-set-attribute "%s" metadata::custom-icon "%s"' % (path, image))
else:
print "no image found for %s/%s" % (root, d)
if not options.recursive:
dirs[:] = []
print "done."

if __name__ == "__main__":
main()

sjosul 1. November 2009, 08:48

Thanks qos

sjosul 3. November 2009, 01:09

I have also found a very simple app here: http://software.flogisoft.com/cover-thumbnailer/en/

From the site:

"Cover thumbnailer is a small Python script which displays music album covers in nautilus, preview of pictures which are in a folder and more.

The script fits in nautilus like any other thumbnailer of the GNOME thumbnail factory; so you don't have to run it manually to generate thumbnails.

Cover thumbnailer is free software under GNU GPL v3+ licence, you are free to modify and redistribute it under the terms of the license."

I just installed it in Karmic, logged out and back in, and it worked immediately for all folders with images. My music album folders (all with folder.jpg in them come up as cd jewel cases; picture and photographs come up as photo albums. other folders with folder.jpg in them come up as an image with a flip fold on the bottom left corner.

So far, a very nice addition to Nautilus.

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies