List of icon filenames

Style your desktop
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Luttim
Level 1
Level 1
Posts: 47
Joined: Fri Dec 10, 2021 5:58 am

List of icon filenames

Post by Luttim »

Is there a quick way to generate a .txt list of all the app icon filenames that ship with mint by default?
cinnamon 20.3
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 3 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
xenopeek
Level 25
Level 25
Posts: 29511
Joined: Wed Jul 06, 2011 3:58 am

Re: List of icon filenames

Post by xenopeek »

Icon names of your installed applications are in the .desktop files in /usr/share/applications/ directory. The .desktop file specification spells out the Icon key in these files specifies the icon name, or full path to the icon: https://specifications.freedesktop.org/ ... 01s06.html

So you can do a command like:
grep Icon= /usr/share/applications/*.desktop | cut -d'=' -f2 | sort -u
and that will get you all the unique Icon keys from those files.

The Icon Theme specification linked from the above page spells out how you find the icon files, if the Icon key isn't a full path (most aren't). In short you'll find the icon files (the images) in the /usr/share/icons/<icon theme name>/<icon resolution>/ directories. That is a much longer list because your icon theme has icons for many, many applications—not just those installed. You can also use those icon names, from the icon theme you are using.
Image
Luttim
Level 1
Level 1
Posts: 47
Joined: Fri Dec 10, 2021 5:58 am

Re: List of icon filenames

Post by Luttim »

Brilliant. Thanks!

EDIT: That worked exactly as I asked. However I now realise I want to do something different:
1) I would like to output appname, iconname next to each other like that (eg. Blueberry, Bluetooth). appname as per Exec and iconname as per Icon. How do I change the command for this output?

And a further question. Some names are straight forward. The Icon for 'audacity' is 'audacity'. But some things are quite strange. The Icon for 'yelp' is 'org.gnome.yelp'. Is there any particular reason for that?
user6c57b8
Level 2
Level 2
Posts: 52
Joined: Mon Aug 05, 2019 1:07 pm

Re: List of icon filenames

Post by user6c57b8 »

Luttim wrote: List of icon filenames ... I would like to output appname, iconname next to each other like that (eg. Blueberry, Bluetooth). appname as per Exec and iconname as per Icon. How do I change the command for this output?
I 900%hope you like perl scripts..

Here is the output of the perl script on my system:

Code: Select all

arandr, display
atril, atril
uxterm, mini.xterm
xterm, mini.xterm
display-im6.q16, display-im6.q16
elementary_config, elementary
fcitx-config-gtk3, fcitx
fcitx-configtool, fcitx
fcitx-skin-installer, fcitx
fcitx, fcitx
fcitx5-configtool, org.fcitx.Fcitx5
fotoxx, /usr/share/fotoxx/icons/fotoxx.png
gcr-prompter, security-medium
WARNING: File '/usr/share/applications/gcr-viewer.desktop' has no Icon=    ...continuing anyway at desktop-shortcut-printjob.pl line 50.
gcr-viewer, 
agent, mark-location-symbolic
google-chrome-stable, google-chrome
gparted, gparted
ibus-setup-hangul, ibus-setup-hangul
WARNING: File '/usr/share/applications/ibus-setup-m17n.desktop' has no Icon=    ...continuing anyway at desktop-shortcut-printjob.pl line 50.
ibus-setup-m17n, 
WARNING: File '/usr/share/applications/ibus-setup-mozc-jp.desktop' has no Icon=    ...continuing anyway at desktop-shortcut-printjob.pl line 50.
mozc_tool, 
im-config, input-keyboard
info, dialog-information
hexchat, hexchat
kasumi, kasumi
kbd-layout-viewer5, input-keyboard
ktelnetservice5, utilities-terminal
xlinks2, links2
mlterm, mlterm-icon-24colors-1
mousepad, org.xfce.mousepad
nm-applet, nm-device-wireless
nm-connection-editor, preferences-system-network
WARNING: File '/usr/share/applications/notification-daemon.desktop' has no Icon=    ...continuing anyway at desktop-shortcut-printjob.pl line 50.
notification-daemon, 
fcitx5-config-qt, org.fcitx.Fcitx5
fcitx5-migrator, org.fcitx.Fcitx5
fcitx5, org.fcitx.Fcitx5
ibus, ibus
ibus-extension-gtk3, ibus
ibus-setup, ibus-setup
epiphany, org.gnome.Epiphany
evince-previewer, document-print-preview
evince, org.gnome.Evince
WARNING: File '/usr/share/applications/org.kde.kded5.desktop' has no Exec=    ...ignoring this desktop file at desktop-shortcut-printjob.pl line 43.
xfce4-panel, application-x-executable
xfce4-panel, org.xfce.panel
pavucontrol, multimedia-volume-control
python3.9, /usr/share/pixmaps/python3.9.xpm
ristretto, ristretto
mozc_tool, /usr/share/icons/mozc/product_icon_32bpp-128.png
synaptic-pkexec, synaptic
system-config-printer, printer
thunar, org.xfce.thunar
thunar-settings, org.xfce.thunar
thunar-volman-settings, org.xfce.volman
thunar, org.xfce.thunar
uim-pref-gtk, /usr/share/uim/pixmaps/uim-icon.png
vim, gvim
vlc, vlc
xarchiver, xarchiver
xchm, xchm
xdg-desktop-portal-gtk, applications-system-symbolic
xfdesktop-settings, org.xfce.xfdesktop
xfce4-display-settings, org.xfce.settings.display
xfce4-keyboard-settings, org.xfce.settings.keyboard
xfce4-mouse-settings, org.xfce.settings.mouse
xfce4-session-settings, org.xfce.session
xfce4-settings-manager, org.xfce.settings.manager
xfce4-appearance-settings, org.xfce.settings.appearance
xfwm4-settings, org.xfce.xfwm4
xfwm4-tweaks-settings, org.xfce.xfwm4-tweaks
xfwm4-workspace-settings, org.xfce.workspaces
xfce4-about, org.xfce.about
xfce4-accessibility-settings, org.xfce.settings.accessibility
xfce4-appfinder, org.xfce.appfinder
xfce4-clipman-settings, xfce4-clipman-plugin
xfce4-clipman, xfce4-clipman-plugin
xfce4-color-settings, org.xfce.settings.color
exo-open, org.xfce.filemanager
exo-open, org.xfce.mailreader
xfce4-mime-settings, org.xfce.settings.default-applications
xfce4-notifyd-config, org.xfce.notification
xfce4-power-manager-settings, org.xfce.powermanager
xfce4-appfinder, org.xfce.appfinder
xfce4-screenshooter, org.xfce.screenshooter
xfce4-sensors, xfce-sensors
xfce4-session-logout, xfsm-logout
xfce4-settings-editor, org.xfce.settings.editor
xfce4-taskmanager, org.xfce.taskmanager
exo-open, org.xfce.terminalemulator
xfce4-terminal, org.xfce.terminal-settings
xfce4-terminal, org.xfce.terminal
exo-open, org.xfce.webbrowser
txiterm, xiterm+thai
xsane, xsane
yelp, org.gnome.Yelp
Here is the perl script/code. You can save it to any text file you want and run: perl the-whatever-text-file.txt

Code: Select all

#!/usr/bin/perl

use warnings;
use strict;

#converts '/whatever/bin/app-name -option1 -option2' into 'appname'
sub exec2appname{
  my ($exec) = @_;
  my $appname = $exec;
  undef $exec;
  $appname =~ s# .*$##; 
  (undef,$appname) = ($appname =~ m{^(.*/)?(.*)}s); #ripped from /usr/share/perl/5.32.1/File/Basename.pm
  return $appname;
}

binmode(STDOUT, ':unix'); #a trick to make STDERR/warnings print in-sync with STDOUT
                          #(copied from `perldoc -q flush`)

my @desktop_files = </usr/share/applications/*.desktop>;
for my $desktop_filename (@desktop_files){
  open(my ${f}, "<$desktop_filename") or die $!;
  my $exec = '';
  my $appname = '';
  my $icon = '';
  while(<$f>){ #read line-by-line
    chomp;
    if(/^Exec=(.*)/){
      $exec = $1;
      if($exec eq ''){
        warn "WARNING: File '$desktop_filename' has an empty Exec=    ...ignoring this desktop file";
        next;
      }
      $appname = exec2appname($exec); 
    }
    if(/^Icon=(.*)/){$icon = $1;}
  } 
  close(${f}) or die $!;
  if($exec eq ''){
    warn "WARNING: File '$desktop_filename' has no Exec=    ...ignoring this desktop file";
    next;
  }
  if($appname eq ''){
    die "CRITICAL: My conversion of '${desktop_filename}'s Exec= to an app name 900\%failed ...critical error";
  }
  if($icon eq ''){
    warn "WARNING: File '$desktop_filename' has no Icon=    ...continuing anyway";
  }
  print qq/$appname, $icon\n/;
}
you can ignore the warnings/errors output with:
perl the-whatever-text-file.txt 2>/dev/null
User avatar
xenopeek
Level 25
Level 25
Posts: 29511
Joined: Wed Jul 06, 2011 3:58 am

Re: List of icon filenames

Post by xenopeek »

Didn't see your edit before.
Luttim wrote: Thu May 19, 2022 8:06 am 1) I would like to output appname, iconname next to each other like that (eg. Blueberry, Bluetooth). appname as per Exec and iconname as per Icon. How do I change the command for this output?
To get that output you can use this command:
for f in $(grep -l '^Icon=' /usr/share/applications/*.desktop); do echo "$(basename "$(grep -m 1 '^Exec=' "$f" | cut -d'=' -f2 | cut -d' ' -f1)"), $(grep -m 1 '^Icon=' "$f" | cut -d'=' -f2)"; done | sort
It's a bit more complicated. But basically what this does is first get a list of the desktop files that have an Icon key in them (not all of them do) and iterate over that list, grepping the first Exec (there can be multiple, for actions) and first Icon key from each and printing those (basename for the Exec key, and arguments removed) with a comma between.

I would use the Name key instead of the Exec key, to get the display name of the program, and neatly put the Name and Icon keys in columns instead of comma separated. With this command:
for f in $(grep -l '^Icon=' /usr/share/applications/*.desktop); do echo "$(grep -m 1 '^Name=' "$f" | cut -d'=' -f2)"$'\t'"$(grep -m 1 '^Icon=' "$f" | cut -d'=' -f2)"; done | column -t -s$'\t' | sort
But it depends on where/how you'll use the list of course :)
Luttim wrote: Thu May 19, 2022 8:06 am And a further question. Some names are straight forward. The Icon for 'audacity' is 'audacity'. But some things are quite strange. The Icon for 'yelp' is 'org.gnome.yelp'. Is there any particular reason for that?
Yes, to avoid name clashes when multiple programs would use the same name for their icons. For this reason GNOME programs and others use fully qualified names. That is, if there would be two programs called "yelp" that each had an icon called "yelp" that wouldn't work. By using the fully qualified name this problem doesn't happen.
Image
Locked

Return to “Themes, Icons & Wallpaper”