6

I am working on a package for a custom application and cannot get my applications icons to display. Here is my desktop file, which is installed in /usr/share/applications:

[Desktop Entry]
Version=1.0
Type=Application
Name=Map Creator
Icon=ntfmo-map-creator
TryExec=/opt/ntfmo/map_creator/bin/map_creator
Exec=/opt/ntfmo/map_creator/bin/map_creator.sh
Categories=Office;
X-Desktop-File-Install-Version=0.16

I have copied images to the following locations:

  • /usr/share/icons/hicolor/32x32/apps/ntfmo-map-creator.png
  • /usr/share/icons/hicolor/48x48/apps/ntfmo-map-creator.png
  • /usr/share/icons/hicolor/scalable/apps/ntfmo-map-creator.svg

I have rebooted, but still nothing. Do you have to register the icons or something?

[EDIT] Ok, I got it to work by running sudo rm -f /usr/share/icons/*/icon-theme.cache, but that seems a little draconian. Is that the "correct" solution? Does my package need to run that after it installs? Seems a little much....

Dave
  • 189
  • 2
    I think you are supposed to call gtk-update-icon-cache as per http://manpages.ubuntu.com/manpages/natty/man1/gtk-update-icon-cache.1.html – fossfreedom Oct 04 '11 at 19:15

1 Answers1

12

Add gtk-update-icon-cache /usr/share/icons/hicolor to your debian/postinst file:

#!/bin/sh

gtk-update-icon-cache /usr/share/icons/hicolor

exit 0
Isaiah
  • 59,344
  • OK, thanks, this is working. Although I also noticed that ubuntu automatically updates the cache when icons are added as part of a package, but not when you manually drop them in. – Dave Oct 05 '11 at 12:35
  • gtk-update-icon-cache checks the timestamp on the top-level icon directory, so you also need to touch that. The only documentation I can find for this is here: https://fedoraproject.org/wiki/Packaging:Scriptlets#Icon_Cache – Brendan Long Feb 18 '17 at 18:51
  • Wow....8 years later and this worked for me on Ubuntu 18.04. Thank you! – DevOpsSauce Nov 19 '19 at 20:27