aboutsummaryrefslogtreecommitdiff
path: root/wpdf
blob: df9c71a67097bbc36aa6b33b44fa08f7ffc701a1 (plain)
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
#!/bin/sh

# wpdf -- view, watch and remake pdf

IFS='
'

[ -z "$*" ] && { echo usage: $0 source-file ... 1>&2; exit 1; }

success=
for source in "$@"; do
	case $source in
	*.pdf)	echo skipping $source: already a pdf 1>&2 ;;
	*)	success=1
		xpdf -remote wpdf-$source ${source%.*}.pdf & ;;
	esac
done

[ -z "$success" ] && exit 1
xdotool search --sync --onlyvisible --class xpdf 1>&-
sleep 0.2 || sleep 1

watch -i "$@" | while read source; do
	make ${source%.*}.pdf && xpdf -remote wpdf-$source -reload
done