Skip to content

Instantly share code, notes, and snippets.

@linuxCowboy
Created March 22, 2019 21:41
Show Gist options
  • Save linuxCowboy/e97686ccace8e76883984ccb8151add3 to your computer and use it in GitHub Desktop.
Save linuxCowboy/e97686ccace8e76883984ccb8151add3 to your computer and use it in GitHub Desktop.
launcher script for mupdf-x11
#!/bin/sh
cmd="/usr/lib/mupdf/mupdf-x11"
ext=".gz .Z .xz .bz2"
file=""
cmdtmp=$cmd
i=1
while [ $i -le $# ]; do
arg=$(eval echo \$$i)
i=$((i += 1))
for j in $ext; do
if [ "${arg#${arg%$j}}" = $j ]; then
file="$arg"
page=$(eval echo \$$i)
break 2
fi
done
cmdtmp="$cmdtmp $arg"
done
test "$file" || exec $cmd "$@"
tmp=$(tempfile -s .pdf)
case "$file" in
*.gz|*.Z) zcat -- "$file" > $tmp && file=$tmp;;
*.xz) xzcat -- "$file" > $tmp && file=$tmp;;
*.bz2) bzcat -- "$file" > $tmp && file=$tmp;;
esac
trap 'rm -f $tmp' EXIT
cmdtmp="$cmdtmp $file $page"
$cmdtmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment