#!/bin/sh
#
# Wouter Bolsterlee <wbolster@gnome.org>, 2011
#
# This script creates a Nautilus thumbnailer specification file for creating
# thumbnails for office documents, such as those created by LibreOffice,
# OpenOffice or Microsoft office. The thumbnailing functionality is provided by
# the binaries shipped with libgsf (packaged as libgsf-bin in Debian and
# Ubuntu). This script just reads the information in the old-style GConf-based
# libgsf thumbnailer definition, which is shipped with the libgsf binaries.
#
# Usage: save the output of this script as a world-readable file in
# /usr/share/thumbnailers/gsf-office.thumbnailer, e.g. by running these
# commands in a shell:
#
#   $ ./convert-libgsf-thumbnailer-definition | sudo tee /usr/share/thumbnailers/gsf-office.thumbnailer
#   $ sudo chmod 644 /usr/share/thumbnailers/gsf-office.thumbnailer
#

GCONF_SCHEMAS=/usr/share/gconf/schemas/gsf-office-thumbnailer.schemas

Exec=$(fgrep gsf-office-thumbnailer $GCONF_SCHEMAS |uniq |sed -e 's/^.*<default>//' -e 's/<\/default>//')
TryExec=$(echo ${Exec} | sed -e 's/ .*//')
BinPath=$(dirname $(which ${TryExec}))/
MimeType=$(fgrep '<key>' $GCONF_SCHEMAS |sed -e 's/^.*thumbnailers./'/ -e 's/\/.*$//' -e 's/@/\//' |uniq |paste -s -d ';')

echo '[Thumbnailer Entry]'
echo 'TryExec='${BinPath}${TryExec}
echo 'Exec='${BinPath}${Exec}
echo 'MimeType='${MimeType}

