Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking for a way to use the icons from the users theme (in gnome) in a bash script.

The solution could be a environment variable or a file where the path to the users icon set is written.

Eg. of use :

notify-send --icon=$MYICONPATH/status/32/info.svg "info"
share|improve this question
up vote 2 down vote accepted

Assuming you are using the GNOME environment, you can get the name of the icon theme with gconftool-2 (Ubuntu versions < 11.04) or gsettings (Ubuntu >= 11.04). Depending on your use case, that might already be enough:


ICON_THEME=$(gconftool-2 -g /desktop/gnome/interface/icon_theme)


ICON_THEME=$(gsettings get org.gnome.desktop.interface icon-theme)
share|improve this answer
Perfect, just what I was looking for! And what if my icons where in /home/user/.icons/ ? Can gconftool find that to? – danjjl Aug 13 '11 at 11:08
@danjjl: No, gconf/gsetting only has the name of the theme -- translating this into the path would need library functions like in Oli's python script. You could of course test for the file existing in ~/.icons first and then fall back to /usr/share/icons if it does not exist. – Marcel Stimberg Aug 13 '11 at 11:22

I don't know how to do it directly from a bash script but I've just written a little Python script that you can use as a utility to help you:

#!/usr/bin/env python

import gtk, sys

theme = gtk.icon_theme_get_default()
icon =  theme.lookup_icon(sys.argv[1], int(sys.argv[2]), ())

if icon: print icon.get_filename()

Save that as somewhere and (optionally) chmod +x it.

Then you can call it, chucking in the icon name and the size, and it'll respond with a path. Example:

$ ./ evolution 32

If you'd rather keep everything in one place (certainly understandable for one-off scripts), you can inline the python like so:

python -c 'import gtk, sys; theme = gtk.icon_theme_get_default(); icon = theme.lookup_icon(sys.argv[1], int(sys.argv[2]), ()); print icon.get_filename() if icon else ""' evolution 32
share|improve this answer
I knew about this way of doing but I was looking for a bash way of doing it, thank you anyway – danjjl Aug 13 '11 at 11:06
It's a better solution than just munging the paths together and hoping it works. With this it finds the nearest possible icon (it'll fall back) at the closest available size. – Oli Aug 13 '11 at 15:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.