Fix thumbnail preview on XDG Desktops (#4078)

Merged, abandoned or rejected pull requests are moved here to clear the main Pull Requests forum.
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Fix thumbnail preview on XDG Desktops (#4078)

Post by wmayer »

Hooray! I got it working!

On my system I neither use the .deb packages nor an AppImage but complie FreeCAD locally.

When I tried to activate thumbnails the first time I could see that FreeCAD files got the same icon as for text documents (before it was the icon of compressed files) and that in the /tmp folder there were many files of the form tumbler-<XXXXXXX>.png that all were empty. So, this possibly was the reason why the thumbnails for FCStd files were wrong.

Additionally I now installed the packages tumbler-plugins-extra and thunar-gtkhash. And I entered this into the terminal

Code: Select all

thunar -q
The most important point is to make the tumbnailer script executable for all groups, i.e chmod a+x instead of chmod u+x

Here is a list of all steps I have performed:
  1. Install tumbler-plugins-extra and thunar-gtkhash
  2. sudo cp src/Tools/freecad-thumbnailer /usr/bin/
  3. sudo chmod a+x /usr/bin/freecad-thumbnailer
  4. sudo cp src/Gui/Icons/freecad-icon-48.png /usr/share/icons/hicolor/48x48/apps/freecad.png
  5. sudo cp src/XDGData/FreeCAD.thumbnailer /usr/share/thumbnailers/
  6. cp src/XDGData/org.freecadweb.FreeCAD.xml ~/.local/share/mime/packages
  7. update-mime-database ~/.local/share/mime/
  8. sudo update-mime
  9. rm -rf ~/.cache/thumbnails/*
  10. thunar -q
Hint:
If a thumbnailer shouldn't be used and you want to show a generic icon instead then run:
xdg-icon-resource install --context mimetypes --size 64 src/Gui/Icons/freecad-doc.png application-x-extension-fcstd

This will create the file $HOME/.local/share/icons/hicolor/64x64/mimetypes/
drmacro
Veteran
Posts: 8866
Joined: Sun Mar 02, 2014 4:35 pm

Re: Fix thumbnail preview on XDG Desktops (#4078)

Post by drmacro »

I now have it working on one PC and not the other (the laptop I was trying to set up previously).

Same OS on both.

I did a diff of the files and they are all the same.

I've compared the versions on the packages in stalled on both.

Yet the desktop PC Thunar gets the preview and on the laptop it does not.

I'm stumped. :(
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Fix thumbnail preview on XDG Desktops (#4078)

Post by wmayer »

I've compared the versions on the packages in stalled on both.
And did you apply chmod a+x to the script?

In the Thunar settings make sure that thumbnails are activated. Either set it to "Always" or "Only for local files".

And in the file /var/log/syslog can you see anything about the FreeCAD thumbnailer being registered by the system?
pachiburke
Posts: 11
Joined: Tue Nov 24, 2020 9:46 am

Re: Fix thumbnail preview on XDG Desktops (#4078)

Post by pachiburke »

Great news!
drmacro
Veteran
Posts: 8866
Joined: Sun Mar 02, 2014 4:35 pm

Re: Fix thumbnail preview on XDG Desktops (#4078)

Post by drmacro »

wmayer wrote: Thu Nov 26, 2020 8:16 pm
I've compared the versions on the packages in stalled on both.
And did you apply chmod a+x to the script?

In the Thunar settings make sure that thumbnails are activated. Either set it to "Always" or "Only for local files".

And in the file /var/log/syslog can you see anything about the FreeCAD thumbnailer being registered by the system?
Referring to the laptop where it does not work.
It appears the thumbnails are being generated. But, thunar is not displaying them. (i.e. they appear in the ~/.cache/thumbnails/)

The answers to the above questions:
  • Yes, double checked
  • Yes, other apps thumbnails are display
  • Yes
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
drmacro
Veteran
Posts: 8866
Joined: Sun Mar 02, 2014 4:35 pm

Re: Fix thumbnail preview on XDG Desktops (#4078)

Post by drmacro »

This is turning out to be a real mystery. :(

I decided to dig into this way deeper than I want to, but now it's sort of a challenge...

I started by adding python syslog to the freecad-thumbnailer.

Then I set up file system monitoring on the ~/.cache/thumbnails folder and /usr/bin/freecad-thumbnailer file using inotify in a terminal window for each.
In addition I set up a tail -f on /var/log/syslog

On the desktop that works, when I touch a freecad file that has a thumbnail:
  • access to the freecad-thumbnailer is logged by inotify
  • logging from freecad-thumbnailer to syslog is seen
  • additons to the ~/.cache/thumbnails (the creation of the .png) is logged by inotify
  • thunar presents the thumbnail
Same setup on the not working machine:
  • access to the freecad-thumbnailer logged by inotify
  • no logging from freecad-thumbnailer to syslog is seen
  • no additons to the ~/.cache/thumbnails are logged by inotify
It appears freecad-thumbnailer is being called but never executes. :?
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Fix thumbnail preview on XDG Desktops (#4078)

Post by wmayer »

Same setup on the not working machine:
Does it create empty files of the form tumbler-XXXXXXX.png inside /tmp?
drmacro
Veteran
Posts: 8866
Joined: Sun Mar 02, 2014 4:35 pm

Re: Fix thumbnail preview on XDG Desktops (#4078)

Post by drmacro »

wmayer wrote: Sun Nov 29, 2020 6:55 pm Does it create empty files of the form tumbler-XXXXXXX.png inside /tmp?
Yes, on both machines.

But, they disappear on the working machine.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
wmayer
Founder
Posts: 20243
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Fix thumbnail preview on XDG Desktops (#4078)

Post by wmayer »

drmacro wrote: Sun Nov 29, 2020 7:17 pm
wmayer wrote: Sun Nov 29, 2020 6:55 pm Does it create empty files of the form tumbler-XXXXXXX.png inside /tmp?
Yes, on both machines.

But, they disappear on the working machine.
This is exactly the behaviour I had too when it was not working. As a next step modify /usr/bin/freecad-thumbnailer to e.g. write some content to a file in /tmp. If this file isn't created means that the script just won't be executed.

There are two things I can imagine why:
  1. The script is not marked as executable
  2. /usr/bin/python is a symlink to the actually used Python version. Maybe the symlink doesn't exist
As a simple test execute the script manually:

Code: Select all

/usr/bin/freecad-thumbnailer -s 128 /tmp/test.FCStd /tmp/test.png
drmacro
Veteran
Posts: 8866
Joined: Sun Mar 02, 2014 4:35 pm

Re: Fix thumbnail preview on XDG Desktops (#4078)

Post by drmacro »

wmayer wrote: Mon Nov 30, 2020 10:07 am
/usr/bin/python is a symlink to the actually used Python version. Maybe the symlink doesn't exist
AHA! the smoking gun. :o

why that symlink was not on the laptop, I have no idea.

But, fixed that and we have lift off.

Now working on both machines. :D

Thanks for all the help!
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
Post Reply