4

I have Guitar Pro installed on my system (no easy task, but that's another matter for another time), and have a ton of .gpx, .gp5, and .gp4 files that I use with the application.

The file icons currently just show up as chequered: Blank file types

I have a decent icon that I can use, but I don't know how to change the icon for specific file suffixes. Can anybody help?

4

Create a New Mimetype

We have to teach the system about GuitarPro as something called a "mimetype". To do that, we need to create a mimetype package file that contains info about how to identify GuitarPro files.

  1. Create a new file called "guitarpro.xml" at "/usr/share/mime/packages"
  2. In this file we need to make some rules about how to match files to this mimetype and what to call it. Enter the following:

    <?xml version="1.0" encoding="UTF-8"?>
    <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
        <mime-type type="application/x-guitarpro">
            <sub-class-of type="application/octet-stream"/>
            <comment>Guitar Hero Pro</comment>
            <glob pattern="*.gpx"/>
            <glob pattern="*.gp4"/>
            <glob pattern="*.gp5"/>
        </mime-type>
    </mime-info>
    

    If you want different icons for each of these extensions you can add more <mime-type> elements to this same file. Just make sure to change that string application/x-guitarpro to something unique for each new mimetype. The above example matches all of these extensions to the same mimetype.

  3. Save the file and open Terminal. Now we need to update the mimetypes list from our definition:

    sudo update-mime-database /usr/share/mime/
    

Create an Icon

Icon names are matched to that string you created in your <mime-type> element with the exception that we replace / with -.

  1. Name your icon "application-x-guitarpro" or whatever else you called it.
  2. Copy this icon to the location "/usr/share/icons/hicolor/SIZE/mimetypes" where "SIZE" is the size of your icon.1
  3. Close and reopen Files. You should now see your icon for these mimetypes.

1The default icon view uses 64px icons. The default list view uses 32px icons. The file chooser dialog uses 16px icons. I recommend creating icons at each of these sizes to make sure they are sharp and legible. If you only have one size, use the "scalable" directory.

  • I did this using an svg and a png, and neither seemed to work. The mimetype is application/octet-stream and doing a grep 'octect' /etc/mime.types shows that this already exists as a mimetype. Do I need to replace something? – Bill O'Dwyer Jan 17 '16 at 11:47
  • 1
    Thanks! This worked perfectly, but I did have to run gtk-update-icon-cache as root before the icons showed. – Bill O'Dwyer Jan 27 '16 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.