Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a launcher on my desktop and want to add another one manually with the same icon.

When I go to the preferences of the existing launcher and click the icon, it doesn't take me to the folder where the icon is stored but just to my home folder.

How can I find out where the used icon of the launcher is located in my system?

share|improve this question

3 Answers 3

up vote 5 down vote accepted

Most of the time, the icon will be chosen from your current icon theme, rather than being referred to as an absolute path.

  1. Open Gedit
  2. Drag the launcher into the Gedit window
  3. Look for the Icon definition:

    Icon=gnome-panel-launcher

You can then find the icon somewhere in /usr/share/icons, depending on your theme.

Here's a quick python script that finds the correct icon path for you:

import gtk

print "enter the icon name (case sensitive):"
icon_name = raw_input(">>> ")
icon_theme = gtk.icon_theme_get_default()
icon = icon_theme.lookup_icon(icon_name, 48, 0)
if icon:
    print icon.get_filename()
else:
    print "not found"

Save it somewhere and run python /path/to/script.py.

It'll look like this:

stefano@lenovo:~$ python test.py 
enter the icon name (case sensitive):
>>> gtk-execute
/usr/share/icons/Humanity/actions/48/gtk-execute.svg

Alternatively, you can just rummage around in /usr/share/icons until you find the icon you're looking for.


Much easier: you can just copy and paste the launcher and change the name and command

share|improve this answer
3  
Another common path to check is /usr/share/pixmaps. –  htorque Jul 9 '11 at 14:38
    
@Stefano: Hero! Thank you very much for both of your answers. Works brilliant. At least the 2nd way should have come to my mind too. –  Timo Schneemann Jul 9 '11 at 18:13

A little more info.

Normal launchers are really .desktop files in /usr/share/applications/.

For example: /usr/share/applications/usb-creator-gtk.desktop

(See http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html)

Each desktop file has a line that specifies the icon, for example:

Icon=usb-creator-gtk

When there is no path (and file extension) (as in this case), it means the icon is found (somewhere) in /usr/share/icons/ and the one used at run-time depends on the current theme and in some cases the display context (size).

Knowing the icon name (without extension) from the desktop file, one can find it/them as follows:

$ find . -name "usb-creator-gtk*"
./hicolor/scalable/apps/usb-creator-gtk.svg
./Humanity/apps/32/usb-creator-gtk.svg
./Humanity/apps/16/usb-creator-gtk.svg
./Humanity/apps/22/usb-creator-gtk.svg
./Humanity/apps/24/usb-creator-gtk.svg
./Humanity/apps/64/usb-creator-gtk.svg
./Humanity/apps/48/usb-creator-gtk.svg
share|improve this answer

This is based from Stefano Palazzo's answer here.

#!/usr/bin/env python3

from gi.repository import Gtk

icon_name = input("Icon name (case sensitive): ")
if icon_name:
    theme = Gtk.IconTheme.get_default()
    found_icons = set()
    for res in range(0, 512, 2):
        icon = theme.lookup_icon(icon_name, res, 0)
        if icon:
            found_icons.add(icon.get_filename())

    if found_icons:
        print("\n".join(found_icons))
    else:
        print(icon_name, "was not found")

Save the above into a file and run it with python3 /path/to/file.

Differences between Stefano Palazzo's original script are that:

  • This find all resolutions of the icon (not just 48)
  • Uses gi.repository instead of Gtk
  • Uses Python 3 instead of 2
  • Slightly tweaked in other ways
share|improve this answer

Your Answer

 
discard

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.