4

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?

2
  • Edit your question and add the output of mimetype ext18.py; mimetype ex1.py
    – A.B.
    Sep 22, 2015 at 5:00
  • Edit your question and add the output of ls -la /usr/share/thumbnailers
    – A.B.
    Sep 22, 2015 at 9:33

2 Answers 2

1

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)}'
    
0

Ahh, check this out : Icons for source code files are not proper in Ubuntu file manager

Did you try sudo rm -rf ~/.thumbnails/* ~/.cache/thumbnails/*

These files are generated automatically. Please post an answer to this question if the above did not work.

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.