Ubuntu file manager is not showing proper icons

All files of a code language, particularly python, do not display the proper file icons but instead look like text files - this only happens when the file contains some text.

empty file file with text

As you can see the file with no code saved to it ex18.py has the proper icon but ex1.py has code written to it and the icon looks like a .txt file.

How can I fix this?


The configuration for the thumbnailers for your file manager are in

/usr/share/thumbnailers

and the binaries are in

/usr/bin

e.g:

cat evince.thumbnailer

[Thumbnailer Entry]
TryExec=evince-thumbnailer
Exec=evince-thumbnailer -s %s %u %o
MimeType=application/pdf;application/x-bzpdf;application/x-gzpdf;application/x-xzpdf;application/x-ext-pdf;application/postscript;application/x-bzpostscript;application/x-gzpostscript;image/x-eps;image/x-bzeps;image/x-gzeps;application/x-ext-ps;application/x-ext-eps;application/x-dvi;application/x-bzdvi;application/x-gzdvi;application/x-ext-dvi;image/vnd.djvu;application/x-ext-djv;application/x-ext-djvu;image/tiff;application/x-cbr;application/x-cbz;application/x-cb7;application/x-cbt;application/x-ext-cbr;application/x-ext-cbz;application/x-ext-cb7;application/x-ext-cbt;application/oxps;application/vnd.ms-xpsdocument
  1. Identify the thumbnailer configuration for the mimetype

    text/x-python
    

    via

    grep -r 'text/x-python' /usr/share/thumbnailers
    

    or only the file name of the thumbnailer configuration with

    grep -ro 'text/x-python' /usr/share/thumbnailers | awk -F: '{print $1}'
    
  2. Disable the thumbnailer configuration via

    grep -ro 'text/x-python' /usr/share/thumbnailers | awk -F: '{system("sudo chmod o-r " $1)}'
    
  3. Enable via (now you need sudo)

    sudo grep -ro 'text/x-python' /usr/share/thumbnailers | awk -F: '{system("sudo chmod o+r " $1)}'