Created
March 22, 2019 21:41
-
-
Save linuxCowboy/e97686ccace8e76883984ccb8151add3 to your computer and use it in GitHub Desktop.
launcher script for mupdf-x11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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