49

I'm trying to change the icon for application/x-hwp files. I've added the icons to the proper places, and checked it with assoGiate (after reading this thread). It shows that my desired icon is associated with the file type. Nevertheless, Nautilus is still showing the old icon. How can I make Nautilus show the correct icon?

4
  • askubuntu.com/questions/39139/…
    – Rinzwind
    Jul 7, 2011 at 8:36
  • @Rinzwind: Thanks. Unfortunately, that link solves a different problem. It's based on changing the icons of individual files. I want to change the default icon for all files of a given type. Jul 7, 2011 at 13:47
  • Are you using a custom icon theme? That could be interfering with the icon that is supposed to show up.
    – RBurgundy
    Jul 7, 2011 at 19:23
  • I'm using the stock Ambiance theme. Anyway, it shouldn't matter, because to my knowledge no icon themes cover this file type. I'm just getting the icon that appears by default when Nautilus doesn't know what other icon to display. Additionally, icon themes are hierarchical, so if an appropriate icon can't be found in the current theme, the hierarchy will be searched, ultimately culminating with the hicolor theme. My icons are installed in both the ubuntu0mono-dark and hicolor themes. Jul 7, 2011 at 23:42

3 Answers 3

31
+50

Here is a set of instructions that should get you a custom icon for hwp files.

Open a terminal :

  • Check the MIME type exists : grep 'hwp' /etc/mime.types

    if you get an output resembling application/x-hwp hwp skip the next step.

  • Create the MIME type sudo -H gedit /etc/mime.types and add the line application/x-hwp hwp

  • Add the icon (which must be called application-x-hwp.svg):

    sudo cp PathToIcon/application-x-hwp.svg /usr/share/icons/gnome/scalable/mimetypes
    

    (don't forget to replace PathToIcon)

Got the information from here

5
  • Thanks for the suggestion. I haven't had a chance to try it thoroughly yet (so far, no success), but I'm awarding the bounty because the other suggestions haven't worked and I won't have a chance to work on this any more before the bounty expires. Aug 14, 2011 at 15:22
  • You maybe should check if your icon theme inherits from gnome (most icon themes do). You will find that information in index.theme located in the directory of your icon set
    – danjjl
    Aug 14, 2011 at 16:03
  • You also need to check ~/.local. For example ~/.local/share, which mimics the folder /usr/local/share. Your locally installed application (i.e. application for you only, not other logins), may have their properties there. Edit similar files, for example, ~/.local/share/icons/XXXX/XXXX
    – Robin Hsu
    Jun 19, 2018 at 9:51
  • 1
    @danjjl: What do you mean with (don't forget to replace PathToIcon) ? Jul 1, 2019 at 8:46
  • 1
    @JoKalliauer in the command to copy the icon to /usr/share/... . I refer to PathToIcon. This needs to be substituted with the path to the icon on your PC. (if you think this could be formulated more clearly don't hesitate to propose an edit)
    – danjjl
    Jul 2, 2019 at 9:40
20

The main trick is to find out correctly where the actual icons are located.
In order to determine that let's analyze HTML icons. Naming convention for the icons is the same as for the MIME-type, only / is replaced with - and no capital letters are allowed. I.e. MIME-type, say, text/x-changelog will have the icon named text-x-changelog.svg (or png). MIME-type for HTML is text/html. So its icon will be text-html.* If we run the command

find /usr/share/icons/ -type f | grep 'text-html\.'

we will get several places where these icons are placed:

/usr/share/icons/Humanity/mimes/
/usr/share/icons/gnome/NNxNN/mimetypes/
/usr/share/icons/HighContrast/scalable/mimetypes/

If we visit each of them with Nautilus we'll see, that Humanity/ folder contains our current icons, gnome/ - some older ones. HighContrast/ doesn't interest us. So in order to change some icon we should replace the icons located in Humanity/ folder.
Also notice that text-html.svg icons which are scalable and should have been placed into scalable subfolder (that should be logical) are placed into the folders for different sizes instead, in the same way as raster PNG files.

After replace of the icons (in all subfolders according to their sizes) with the desired ones icon cache should be updated:

sudo gtk-update-icon-cache /usr/share/icons/Humanity

That's it.

There's another way to determine the precedence of icon schemes - to check their index.theme files. If we look inside /usr/share/icons/Humanity/index.theme, we'll see:

Inherits=gnome,hicolor

This means that icons from gnome and hicolor folders will have less precedence than the ones from Humanity. This is explained here.
Strangely enough, Nautilus doesn't obey these inheritance rules. When I added new MIME-type, I tried placing its icons into /usr/share/icons/gnome/, /usr/share/icons/hicolor, ~/.local/share/icons/hicolor, updating icon database on each step - all in vain. These icons were displayed properly in assogiate on the first tab, but never in Nautilus. But when I placed them into Humanity folder and updated icon database, they appeared at once.

N.B. All this applies to the default icon theme. If you use some custom icon theme, you should check where the actual icons are located and add/change icons there instead. Also in newer distributions these inheritance rules may change. Then you should locate the new folder which stores the actual icons (if it is not Humanity anymore) as explained previously.

1
  • You also need to check ~/.local. For example ~/.local/share, which mimics the folder /usr/local/share. Your locally installed application (i.e. application for you only, not other logins), may have their properties there. Edit similar files, for example, ~/.local/share/icons/XXXX/XXXX
    – Robin Hsu
    Jun 19, 2018 at 9:51
0

I hope you tried logout and login to refresh icon cache.

See also if your icon is available in proper size (the one you're using to display file type in nautilus).

You also might missed running gtk-update-icon-cache.

Try this tutorial: http://swik.net/Ubuntu/Only+Ubuntu/How+To+Change+File-Type+(mimetype)+Icons+in+Ubuntu/chcrf

Try to manually create icon.theme, here is an example I have from awn:

[Icon Theme]
Name=awn-theme

Directories=scalable

[scalable]
Size=48
MaxSize=256
Context=Apps
Type=Scalable

Manual is here: http://live.gnome.org/GnomeArt/Tutorials/IconThemes

4
  • I've installed a 48x48 icon and set Nautilus to 100%, which uses 48x48. No dice. Re-logging in makes no difference. Running gtk-update-icon-cache has no effect. Aug 8, 2011 at 8:16
  • I updated my answer, did it help? Aug 8, 2011 at 16:21
  • I haven't manually created an icon theme, because I don't want a new theme. I just want the icon to go into the hicolor theme, because that's the base of all the icon themes. Creating a new theme will defeat my purpose. Aug 11, 2011 at 3:58
  • Both the swik.net and live.gnome.org links in this answer are dead. Sep 20, 2023 at 12:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .