22

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?

19

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


EDIT 2018

Updated version of the script above:

#!/usr/bin/env python3
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

icon_name = input("Icon name (case sensitive): ")
icon_theme = Gtk.IconTheme.get_default()
icon = icon_theme.lookup_icon(icon_name, 48, 0)
if icon:
    print(icon.get_filename())
else:
    print("not found")
  • 5
    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
  • Traceback (most recent call last): File "LookUget.py", line 2, in <module> import gi ImportError: No module named gi – JulianLai Jan 19 '19 at 1:28
5

A little more info.

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

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

(See https://specifications.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
3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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