Xfce Wiki

Sub domains
 

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
xfce:thunar:tumbler [2018/08/24 16:47] – [Customized Thumbnailer for folders] alexxconsxfce:thunar:tumbler [2019/07/20 00:39] – Added text thumbnailer entry toz
Line 70: Line 70:
 ==== Customized Thumbnailer for folders ==== ==== Customized Thumbnailer for folders ====
  
-Another example are albums cover thumbnails for folders in a music collection. Starting with thunar 1.8.2 a custom thumbnailer can be added to e.g. add a file  ''folder.jpg'' or ''cover.jpg'' into a folder and display its thumbnail instead od the default folder icon:+Another example are albums cover thumbnails for folders in a music collection. Starting with thunar 1.8.2 a custom thumbnailer can be added to e.g. add a file  ''folder.jpg'' or ''cover.jpg'' into a folder and display its thumbnail instead of the default folder icon:
 <file txt /usr/share/thumbnailers/folder.thumbnailer> <file txt /usr/share/thumbnailers/folder.thumbnailer>
 [Thumbnailer Entry] [Thumbnailer Entry]
Line 78: Line 78:
 Name=Folder Thumbnailer Name=Folder Thumbnailer
 MimeType=inode/directory; MimeType=inode/directory;
-Exec=/usr/bin/folder-thumbnailer %s %i %o+Exec=/usr/bin/folder-thumbnailer %s %i %o %u
 </file> </file>
  
Line 86: Line 86:
 #!/bin/bash #!/bin/bash
  
-convert -thumbnail "$1" "$2/folder.jpg" "$3" ||\ +convert -thumbnail "$1" "$2/folder.jpg" "$3" 1>/dev/null 2>&||\ 
-convert -thumbnail "$1" "$2/.folder.jpg" "$3" ||\ +convert -thumbnail "$1" "$2/.folder.jpg" "$3" 1>/dev/null 2>&||\ 
-convert -thumbnail "$1" "$2/folder.png" "$3" ||\ +convert -thumbnail "$1" "$2/folder.png" "$3" 1>/dev/null 2>&||\ 
-convert -thumbnail "$1" "$2/cover.jpg" "$3" ||\ +convert -thumbnail "$1" "$2/cover.jpg" "$3" 1>/dev/null 2>&||\ 
-rm -f "$HOME/.cache/thumbnails/normal/$(echo -n "file://$2" | md5sum | cut -d " " -f1).png" ||\ +rm -f "$HOME/.cache/thumbnails/normal/$(echo -n "$4" | md5sum | cut -d " " -f1).png" ||\ 
-rm -f "$HOME/.thumbnails/normal/$(echo -n "file://$2" | md5sum | cut -d " " -f1).png" ||\ +rm -f "$HOME/.thumbnails/normal/$(echo -n "$4" | md5sum | cut -d " " -f1).png" ||\ 
-rm -f "$HOME/.cache/thumbnails/large/$(echo -n "file://$2" | md5sum | cut -d " " -f1).png" ||\ +rm -f "$HOME/.cache/thumbnails/large/$(echo -n "$4" | md5sum | cut -d " " -f1).png" ||\ 
-rm -f "$HOME/.thumbnails/large/$(echo -n "file://$2" | md5sum | cut -d " " -f1).png" ||\ +rm -f "$HOME/.thumbnails/large/$(echo -n "$4" | md5sum | cut -d " " -f1).png" ||\ 
-exit 0+exit 1
 </file> </file>
 +
 +Note: imagemagick is a required dependency for this script.
 +
 +==== Customized Thumbnailer for text-based documents ====
 +A thumbnailer for text-based documents can be created using the convert function from the imagemagick package with the following thumbnailer file:
 +
 +<file txt /usr/share/thumbnailers/text.thumbnailer>
 +[Thumbnailer Entry]
 +Version=1.0
 +Encoding=UTF-8
 +Type=X-Thumbnailer
 +Name=Text Thumbnailer
 +MimeType=text/plain;text/html;text/css;
 +Exec=/usr/local/bin/textthumb %s %i %o
 +</file>
 +
 +And supporting script:
 +
 +<file sh /usr/local/bin/textthumb>
 +#!/bin/bash
 +iFile=$(<"$2")
 +iChopped="${iFile:0:1600}"
 +unset iFile
 +echo "${iChopped}" > tmp.txt
 +unset iChopped
 +convert -size 210x290 -background white -pointsize 5 -border 10x10 -bordercolor "#CCC" caption:@"tmp.txt" "$3"
 +rm tmp.txt
 +</file>
 +
 +You can add additional mime types to the MimeType line of the thumbnailer file to support additional text-based document types.