--- /dev/null
+#!/bin/bash
+
+
+set -x
+TMPDIR="$(mktemp -d)"
+
+mkdir -p "$TMPDIR/a"
+mkdir -p "$TMPDIR/b"
+cp -l "$1" "$TMPDIR/a/file.pdf";
+if [ -e "${1}.annot" ]; then
+ cp "$1" "$TMPDIR/b/file.pdf";
+ chmod u+w "$TMPDIR/b/file.pdf"
+ qprint -d "${1}.annot" | patch -d "$TMPDIR/b" --binary;
+else
+ chmod u+w "$TMPDIR/b/file.pdf"
+ cp "$1" "$TMPDIR/b/file.pdf";
+fi;
+
+
+(cd "$TMPDIR/b"
+ chmod u+w "file.pdf"
+ ## evince really should just use the same document-directory
+ gsettings set org.gnome.Evince document-directory "'file://$TMPDIR/b'";
+ evince "file.pdf"
+);
+
+(cd "$TMPDIR";
+ diff -Nura a b ) | qprint -e > "${1}.annot"
+rm -f "$TMPDIR/a/file.pdf"
+rm -f "$TMPDIR/b/file.pdf"
+rmdir "$TMPDIR/a" "$TMPDIR/b" "$TMPDIR"