26

I want to see what icons are installed and available on my system and by which names I have to refer to them.

How can I get a nicely formatted list of all unique icons (don't show several resolutions separately) that contains the icon name, a preview thumbnail, the location and maybe if possible where it came from (e.g. which icon theme package)?

System: Ubuntu 15.10 Wily Werewolf 64 bit
Desktop: Unity

Byte Commander
  • 107,489
  • 3
    find /usr/share/icons/ -iname '*.png' -or -iname '*.svg' -printf '%h %f %p\n' | sed -r 's;^/usr/share/icons/([^/]*)/[^ ]* ;\1 ;' | sort -u -k1,2 | column -t covers most of it (except the thumbnail part), I'd say. I'm not sure how you expect to see the thumbnail in a list. – muru Nov 09 '15 at 12:05
  • Regarding the "finding out from which package" part: "dpkg-query -S /bin/bash" outputs the package name of the bash executable in the /bin directory (as an example how it works). With only "/bin" as an argument it would output all installed packages for all the files in the /bin directory. – neoc Nov 09 '15 at 11:56
  • @muru In a GUI window? I did not say it should be a command-line solution... – Byte Commander Nov 09 '15 at 12:24
  • @ByteCommander You didn't, but you didn't say what sort of GUI either. Do you expect us to program a GUI for you? – muru Nov 09 '15 at 12:26
  • @muru No, but I thought somebody might maybe know an already existing tool for this? I know I used something like that once, it was probably built into some XFCE function, maybe to select an icon for launchers there... – Byte Commander Nov 09 '15 at 12:30
  • @muru I made a simple bash function to display an icon and its name through the notify-OSD: showicon () ( notify-send $1 -i $1 ) --> Example: showicon terminal – Byte Commander Nov 09 '15 at 12:41
  • Related: http://askubuntu.com/questions/48725/is-there-some-kind-of-icon-browser (not answered to your satisfaction) – muru Nov 09 '15 at 12:41
  • @muru And how would I have to modify your line above to get only the icon names (2nd column, but without file extension)? And how to get only the 3rd column (full path and file name)? – Byte Commander Nov 09 '15 at 12:51
  • How about an icon to a search in /usr/share/icons and /usr/share/pixmaps? – Fabby Nov 09 '15 at 13:09

2 Answers2

35

gtk3-icon-browser is a graphical application to list themed icons.

To this date, it is still under development and available for 15.04 (vivid) and newer releases. Its development can be traced back to this blog post dated 2014.

gtk3-icon-browser with normal and symbolic views

Screenshot 1: gtk3-icon-browser (3.24.18) in Adwaita theme viewing Tango icon theme, with normal (left) and symbolic views

gtk3-icon-browser with different icon themes

Screenshot 2: gtk3-icon-browser (3.24.18) with search input "save" and a pop-up window showing icon details, viewing Tango icon theme (left) and elementary Xfce icon theme

Quick review based on above screenshots:

  • Nicely formatted list of all unique icons: Yes ^1
  • Contains the icon name: Yes ^2
  • Preview thumbnail: Yes
  • Location of icons: No ^3
  • Icon theme origin: Yes ^4

Reference notes:

^1: This tool will show as icon view by default (no way to change into list view). Either single-click or double-click on each icon will show all available resolutions for that icon.

^2: The newer version of icon browser (since 3.22.30 or so) has added a button "Copy to Clipboard" to the pop-up window, which allows to copy the icon name with a single click.

^3: This tool most likely looks into /usr/share/icons directory (without mentioning locations for each icons) and pulls additional information according to the icon naming specification.

^4: This tool only shows the icons for current theme. To show icons for other theme, change appearance of the desktop environment from current theme to another theme.

The icon browser requires GTK+ 3.13.4 or newer. Install the relevant package gtk-3-examples in 15.04 (vivid) or newer releases.

sudo apt-get install gtk-3-examples
gtk3-icon-browser

First tested in 15.04 (vivid), and latest in 20.04 (focal).

Related sources:

  1. Source code of gtk/demos at master for GNOME/gtk on GitHub.

  2. New icon browser tool for GTK+ developers in development on Fedora Magazine

  3. Mentioned briefly with screenshot in this answer on Ask Ubuntu.

  • This solution is almost perfect. It would be if it showed icons from other themes that are not provided by the current theme as well, though. – Byte Commander Nov 10 '15 at 09:26
  • 1
    @ByteCommander somebody should tell A.B. to undelete their answer, which suggested exactly this program. – muru Nov 17 '15 at 11:45
  • @muru Could you please explain your comment? The deleted answer you mentioned is a duplicate of this answer in the sense that it suggests the same application from the same package. Why would the deleted answer provide something more? Am I missing something here? – pomsky Jul 23 '20 at 15:36
  • @pomsky it was posted earlier than this one, and deleted presumably because A.B. thought it wasn't a satisfactory answer after posting. – muru Jul 24 '20 at 07:05
  • @muru Ah, okay, so you asked for the undeletion simply because A.B. deleted it likely under a wrong presumption. I read your comment in a wrong context. I thought it's supposed to be a response to what Byte asked for in the first comment, i.e. the deleted answer tells how to show icons from other themes that are not provided by the current theme as well. – pomsky Jul 24 '20 at 10:52
4

Well, some DEs show this when you try to change the icon of something, but it is quite easy to do it yourself. Just find all icons, make links to them in some directory and browse the directory. The icons of different resolutions will have the same name, what changes is the path. For example:

$ find /usr/share/icons/ -name '*emacs.*' 
/usr/share/icons/hicolor/16x16/apps/emacs.png
/usr/share/icons/hicolor/48x48/apps/emacs.png
/usr/share/icons/hicolor/scalable/apps/emacs.svg
/usr/share/icons/hicolor/128x128/apps/emacs.png
/usr/share/icons/hicolor/32x32/apps/emacs.png
/usr/share/icons/hicolor/24x24/apps/emacs.png
/usr/share/icons/Mint-X/apps/96/emacs.svg
/usr/share/icons/Mint-X/apps/16/emacs.png
/usr/share/icons/Mint-X/apps/24/emacs.png
/usr/share/icons/Mint-X/apps/48/emacs.png
/usr/share/icons/Mint-X/apps/32/emacs.png
/usr/share/icons/Mint-X/apps/22/emacs.png

As you can see above, the general format is /ParentDir/ThemeName/CLass/Resolution/IconName. So, since the icon's name is the same, we can avoid duplicates easily by having each link created overwrite any existing links of the same name. However, we do want to jeep the icons from the different themes separate, so that requires a little bit more scripting:

#!/usr/bin/env bash

## Create the target directory
mkdir -p ~/foo
## Iterate over all files/dirs in the target locations
for i in ~/.icons/* /usr/share/icons/* /usr/share/pixmaps/*; do 
    ## find all icon files in this directory. If the current $i
    ## is not a directory, find will just print its path directly.
    find "$i" -name '*xpm' -o -name '*.svg' -o -name '*png' | 
        ## Iterate over find's results
        while read ico; do 
            ## Make the link. ${var##*/} will print the
            ## basename of $var, without the path. Here, I use
            ## it both to get the theme name (${i##*/}) and the
            ## icon's name (${ico##*/}).         
            ln -sf "$ico" "${i##*/}"_"${ico##*/}"
        done
done

The script above will create the directory ~/foo which will contain links to each of your unique icon files. The -f option to ln tells it to overwrite existing files with the same name and, since we're using the theme name in the link's name, there should be no duplicates. For example, given the emacs.png icons shown above, it will create:

hicolor_emacs.png -> /usr/share/icons/hicolor/48x48/apps/emacs.png
Mint-X_emacs.png -> /usr/share/icons/Mint-X/apps/22/emacs.png

You can now, browse to ~/foo and have a look:

enter image description here

Then, to get the source packages, you could run:

for i in ~/foo/*; do dpkg -S $(readlink -f "$i"); done
terdon
  • 100,812
  • This will however link images of all different available resolutions, right? Can I filter duplicates in different sizes out and just show the largest one? – Byte Commander Nov 09 '15 at 13:58
  • @ByteCommander no it won't. The -f options makes ln overwrite existing links so only one icon of the same name will be shown. However, I just realized that while dupes won't be an issue, you will miss many since all gedit.png icons will be overwritten by the last one found. That's what I wanted to deal with resolutions, but it doesn't deal with different themes: only one theme's icon will be shown. I'm trying to fix that now. – terdon Nov 09 '15 at 17:06
  • @ByteCommander OK, see updated answer. This still has no issue with duplicates but will now correctly show icons from different themes. – terdon Nov 09 '15 at 17:57