Referencing icons in .desktop files
You can simply put the full path in the file or the path to an icon in the default icon directories (explained below)
Adding multiple resolutions to an icon
You can let your own icons have multiple resolutions by placing them in one of the following folders:
Replace <RESOLUTION> with the resolution of the icon (in 48x48 format), replace <NAME> with a unique name you would like to reference it with, replace .png with the extension for the icon (if it has a different one).
For the current user only:
~/.local/share/icons/hicolor/<RESOLUTION>/apps/<NAME>.png
For all users on the system:
/usr/share/icons/hicolor/<RESOLUTION>/apps/<NAME>.png
To reference this icon in a .desktop file, you will use only the <NAME> of it without the extension.
Notes:
The icon must be of PNG, XPM or SVG format, and have the correct file extension
(.png, .xpm or .svg).
If the icon is a .svg (Scalable vector graphics) file, you can use scalable as the <RESOLUTION> in either path above.
References:
Finding icons without a full path
(Use this to locate the icon for chromium-browser, for example)
Inspired by 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())
print("\n".join(found_icons))
Save the above into a file and run it with python3 /path/to/file.
References: