$ git clone http://gcodetool.ion.nu/gcodetool.git
commit d85220cee5250439802e190225a80efa406d6b72
Author: Alicia <...>
Date:   Mon Oct 7 18:39:32 2019 +0200

    Add gcodetool preview as a thumbnail generator for file managers.

diff --git a/Makefile b/Makefile
index 35a9118..cc05f2c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,6 @@
 PREFIX=/usr
 BINDIR=$(PREFIX)/bin
+SHAREDIR=$(PREFIX)/share
 CFLAGS=-Wall -g3
 gcodetool: main.o gcode.o mirror.o move.o info.o preview.o preview_term.o preview_pnm.o
  $(CC) $^ -lm -o $@
@@ -8,3 +9,4 @@ static: gcodetool
 
 install: gcodetool
  install -D gcodetool $(BINDIR)/gcodetool
+ install -D gcodetool.thumbnailer $(SHAREDIR)/thumbnailers/gcodetool.thumbnailer
diff --git a/gcodetool.thumbnailer b/gcodetool.thumbnailer
new file mode 100644
index 0000000..66d7232
--- /dev/null
+++ b/gcodetool.thumbnailer
@@ -0,0 +1,4 @@
+[Thumbnailer Entry]
+TryExec=gcodetool
+Exec=gcodetool preview -s %s -o pnm %o --rx -45 --rz 45 %u
+MimeType=text/x.gcode;text/x.g
diff --git a/preview.c b/preview.c
index fc49091..90b22ea 100644
--- a/preview.c
+++ b/preview.c
@@ -276,6 +276,7 @@ int gtool_preview_arg(int argc, char** argv)
       ,argv[0], argv[1]);
     return -1;
   }
+  if(!strncmp(filename, "file://", 7)){filename=&filename[7];}
 // TODO: Mechanism for selecting method by what's available. Not relevant until there's another direct display method
   if(!imginit){imginit=gtool_preview_term;}
   struct img* img=imginit(width,height,outfile);