Custom thumbnailers don’t work on Ubuntu 18.10 and 18.04

Recently I had a bunch of my own scripts for the thumbnails in Nautilus: WebP previews, sound waveforms, office documents and so on.

Seems like either I’m doing something wrong (thumbnail generation behavior changed), or custom thumbnailes don’t work in latest GNOME at all, even my previous scripts, which worked smoothly on previous versions of Ubuntu.

I’ve done some research, tried to run a simple script (see below) and it didn’t work out.

My test thumbnailer in /usr/share/thumbnailers/z.thumbnailer:

[Thumbnailer Entry]
Exec=/home/maximal/thumb.sh %s %i %u %o
MimeType=image/webp;image/x-webp

Where /home/maximal/thumb.sh is:

#!/bin/bash
echo $0 >> /home/maximal/thumb.log
echo $1 >> /home/maximal/thumb.log
echo $2 >> /home/maximal/thumb.log
echo $3 >> /home/maximal/thumb.log
echo $4 >> /home/maximal/thumb.log

Then, when I remove thumbnail cache rm -rf ~/.cache/thumbnails and restart Nautilus nautilus -q, my log file doesn’t contain anything and ~/.cache/thumbnails/fail/gnome-thumbnail-factory contains all the failed thumbs (looks like corrupted/empty PNGs):

Failed thumbnail file

So, apparently, Nautilus even didn’t try to execute my thumbnailer script.
When I try to run thumb command itself, it works perfectly. For example convert through cwebp|dwebp package:

convert -thumbnail 256x256 file.webp png:file.webp.png

When I wrap this command to a thumbnailer, it looks like it wasn’t even requested to run by Nautilus.

[Thumbnailer Entry]
Exec=convert -thumbnail %sx%s %i png:%o
MimeType=image/webp;image/x-webp;

Exactly the same situation occurs with other my thumbnailers: audio waveforms, office documents, photoshop files and so on.

Could anyone help?

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

I’ve gone thru the same trouble with some of my external thumbnailers.

After some researches, I realised that bubblewarp call fails under Ubuntu and Debian based distros because of –symlink option on /bin and /sbin. In fact under these distros, /bin and /usr/bin are not merged. So, both should be declared with –ro-bind instead of –symlink.

To make bwrap call from Nautilus work under Ubuntu, you need to replace –symlink calls with –ro-bind calls for /bin and /sbin

To solve speed issue with thumbnailers using imagemagick tools, you also need to add a –ro-bind for /etc/alternatives and /var/cache/fontconfig

So, simplest solution is to place a wrapper script under /usr/local/bin/bwrap which will do the job and then call original /usr/bin/bwrap. As /usr/local/bin is before /usr/bin in the PATH, it is transparent for Nautilus.

Wrapper script is available on my Github repo

I’ve written a small article to explain all into details and to provide wrapper script installation instruction. It has been tested under 18.04 and 18.10

http://bernaerts.dyndns.org/linux/360-ubuntu-nautilus-external-thumbnailer-failure

Hope it helps

Solution 2

I’m using 18.04, but after 2018.11.28 update I had same issue. It is caused by sandboxing thumbnailers with bubblewrap (it cost me 2 days of research!!!).

So I downgraded gnome-desktop3-data, gir1.2-gnomedesktop-3.0, libgnome-desktop-3-17 (not sure if all 3 needed) and then removed bubblewrap.

It’s a dirty hack and it weakens the security, but I don’t care…

Maybe it will be not so easy on 18.10.

I hope somebody can write better solution…

Solution 3

I’m using 18.04 and I could not get the solution with the bwrap script to work. I have a thumbnailer somewhere in my home path, which works under 16.04. I can solve it in 18.04 by putting this program in /usr/bin.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply