-
Notifications
You must be signed in to change notification settings - Fork 13
/pdf
executable file
·50 lines (41 loc) · 949 Bytes
/pdf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
# See ~/org/notes/PDFviewers.org for justification on decision order
viewers='kpdf evince okular acroread xpdf'
found=
for file in "$@"; do
if [ -r "$file" ]; then
found=y
else
echo "$file doesn't exist or unreadable!" >&2
fi
done
if [ -z "$found" ]; then
echo "No valid file found; aborting!" >&2
exit 1
fi
# acroread -help gets truncated before echoing 'openInNewWindow'
# when STDOUT is not a tty?!
# if acroread -helpall | grep -q openInNewWindow; then
acro_opts=-openInNewWindow
# else
# acro_opts=
# fi
exe=
for exe_check in $viewers; do
if which $exe_check >/dev/null 2>&1; then
exe=$exe_check
# echo "Will use $exe ..."
break
else
:
# echo "$exe_check not found"
fi
done
if [ -z "$exe" ]; then
echo "No PDF viewer found; aborting." >&2
exit 1
fi
if [ "$exe" = "acroread" ]; then
opts="$acro_opts"
fi
"$exe" $opts "$@"