assign an icon to a file format. HOWTO

Asked by roger64

I have files in .pgn and others in .epub format that I would like to easily recognize on my desktop..
I'd like to assign them a default icon in .png format.

As hard as I can try, I get poor results. I would appreciate if it existed somewhere a recommended method to do it or an example.

I think the problem lies somewhere with the export of file types, or the various update-mime-database commands related to tthe three main mime databases (/usr /usr/local /home/user/.local ).

I think it could be a reference work.

Thanks for your help.

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu nautilus Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Willem Hobers (whobers) said :
#1

Never tried this myself but I found this:

https://help.ubuntu.com/community/AddingMimeTypes

Is this any help?

Revision history for this message
Sam_ (and-sam) said :
#2
Revision history for this message
roger64 (rogqip-suse) said :
#3

Hi, thanks for your quick reply.

  My firts wish is that I could assign a custom icon for some file types I
use extensively. This seems to be a basic user requirement. For this
purpose, the existing official information is not really satisfactory.

My intention is to write later a step by step how-to suitable for plain
users like me. I do hope that somebody will accept to tell me if and where I
am wrong.

*Nature of the problem using assogiate*

If it's easy to assign a custom icon to a file type when the extension
suffix (the file type) is not registered in the system database, it's quite
tricky to do it when the file type is previously registered in the system
database. Let me show it.

Here are five extensions examples, two working, three non working.

- .lrf (proprietary format for Sony electronic books)

Fairly easy. This extension is totally unknown in the system database.
(though an application/x-sony-bbeb exist in the user database brought in by
the "calibre" developer). I add it to the user database using assogiate,
point to a default icon, update the user database and here we go.

- si4 (specific format for SCID chess database files)

Fairly easy. This extension is totally unknown in the database. Same
proceeding as previous one. Same -good- results.

- pgn, epub and odt problems.

Problem arise when the file type has already a generic icon assigned in the
system database. For example, /usr/share/mime/packages/freedesktop.org.xml
includes these icon-related informations:

for pgn file type: <generic-icon name="text-x-generic"/>

for epub file type: <generic-icon name="x-office-document"/>

for odt file type: <generic-icon name="x-office-document"/>

It was inscribed in the generic-icons files this way (for pgn)

mime-type : generic-icon-name

application/x-chess-pgn:text-x-generic

These are indeed the icons I get on my system.

However hard I tried using assogiate, and even if assogiate duly recorded
the name of the the newly given "default icon", there was no way that the
file system would use this new custom icon instead of the generic one.

My conclusion unless I miss something. is that assogiate seems to work only
with "virgin", or brand new file formats. So it seems that we have to find a
workaround for this.

*Trying to find a workaround (ongoing)*

I read that the user can override the standard database using the
"override.xml" file, placed in /home/user/.local/share/mime/packages.

I had a close look at this file and as I did not find any xml element inside
related to icon, I thought about "manually" completing this override.xml
file with a one liner pointing to my newly given custom icon location.

If I took a generic icon name, I thought I would still have to look for a
correct theme location. So my first try was to write a one-liner with a
specific icon name and place for example:

<icon name="/home/user/imageslinux/icones/epub.png"/>

which would hopefully override the previous

<generic-icon name="x-office-document"/>

I updated all the three mime databases locations with the
update-mime-database command but when I looked at the result, I failed.

Is there something I could do up to now to go further ?

2010/11/21 Sam <email address hidden>

> Your question #134769 on nautilus in ubuntu changed:
> https://answers.launchpad.net/ubuntu/+source/nautilus/+question/134769
>
> Sam proposed the following answer:
> http://www.freedesktop.org/wiki/Specifications/AddingMIMETutor
>
> http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec#Tutorials
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
>
> https://answers.launchpad.net/ubuntu/+source/nautilus/+question/134769/+confirm?answer_id=1
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/ubuntu/+source/nautilus/+question/134769
>
> You received this question notification because you are a direct
> subscriber of the question.
>

Revision history for this message
Sam_ (and-sam) said :
#4

Can you help with this problem?

Provide an answer of your own, or ask roger64 for more information if necessary.

To post a message you must log in.