]> git.donarmstrong.com Git - bin.git/blob - evince_annot
Abstract out GIT_HOST
[bin.git] / evince_annot
1 #!/bin/bash
2
3
4 set -x 
5 TMPDIR="$(mktemp -d)"
6
7 mkdir -p "$TMPDIR/a"
8 mkdir -p "$TMPDIR/b"
9 cp -l "$1" "$TMPDIR/a/file.pdf";
10 if [ -e "${1}.annot" ]; then
11     cp "$1" "$TMPDIR/b/file.pdf";
12     chmod u+w "$TMPDIR/b/file.pdf"
13     qprint -d "${1}.annot" | patch -d "$TMPDIR/b" --binary;
14 else
15     chmod u+w "$TMPDIR/b/file.pdf"
16     cp "$1" "$TMPDIR/b/file.pdf";
17 fi;
18
19
20 (cd "$TMPDIR/b"
21  chmod u+w "file.pdf"
22  ## evince really should just use the same document-directory
23  gsettings set org.gnome.Evince document-directory "'file://$TMPDIR/b'";
24  evince "file.pdf"
25 );
26
27 (cd "$TMPDIR";
28  diff -Nura a b ) | qprint -e > "${1}.annot"
29 if ! [ -s "${1}.annot" ]; then
30     rm -f "${1}.annot";
31 fi;
32 rm -f "$TMPDIR/a/file.pdf"
33 rm -f "$TMPDIR/b/file.pdf"
34 rmdir "$TMPDIR/a" "$TMPDIR/b" "$TMPDIR"