3

In Nemo some "twig" files appear with the text icon whilst some appear with a web icon. I want all files with a "twig" extension to appear in Nemo like "html" files e.g. with a web icon. So I edited /etc/mime.types adding the "twig" extension to the html entry:

text/html                   html htm shtml twig

And then updated the MIME database using:

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

However it did not work, the twig files still have mixed icons.

I am running Linux Mint version 18.1.

don_crissti
  • 79,330
  • 30
  • 216
  • 245
gornvix
  • 463
  • 6
  • 17

1 Answers1

3

Use freedesktop's unified system to define a new association.
Write a new source xml file e.g.

~/.local/share/mime/packages/text-twig.xml

with the following content:

<?xml version="1.0"?>
 <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
  <mime-type type="text/html">
    <comment>twig template files</comment>
    <glob pattern="*.twig"/>
  </mime-type>
 </mime-info>

then update your mime database

update-mime-database ~/.local/share/mime

and you're all set.


The above will alter *.twig files mime type for your current user. For a global change follow the same procedure replacing all occurrences of ~/.local with /usr

don_crissti
  • 79,330
  • 30
  • 216
  • 245
  • Is it possible to get a different icon rather than a "text file" icon in Nemo through this method? – gornvix Apr 24 '17 at 17:46
  • Yes. I have type="text/twig" and I am getting a text icon. Although this is another question: can I have a unique (custom) icon for the twig types? – gornvix Apr 24 '17 at 18:23
  • 1
    @tyebillion - yes, see link in my comment above (which sends you to another comment of mine on another question of yours...) – don_crissti Apr 24 '17 at 18:23
  • https://unix.stackexchange.com/questions/177760/where-does-nautilus-get-its-file-type-description other than what you've already said this talks about changing the Nautilus source code which sounds a bit drastic. – gornvix Apr 24 '17 at 19:51
  • There are 2 answers in the link I just referenced above not to mention other further links. – gornvix Apr 24 '17 at 20:08