2 # This wrapper provides automatic reloading on file modifications
3 # to the pdfviewer llpp via inotify.
11 # Return with an error if the given file does not exist.
12 if [ ! -e $pdf ]; then
13 echo "$pdf: No such file or directory"
17 # Start llpp with the given file.
18 llpp
$pdf $passthrough &
20 # Track the PID of the llpp instance.
23 # Kill the llpp instance if the shell script terminates.
24 trap "kill ${pid_llpp}" SIGINT SIGTERM SIGQUIT SIGKILL
26 # Watch for changes in the directory of the given file. This is necessary
27 # to recieve events after the file was deleted.
28 inotifywait
-m -e close_write
"$PWD" -q |
while read dir ev
file; do
29 # Only refresh on events of the file in question and if this file exists.
30 if [ "$file" = "$pdf" ] && [ -e "$pdf" ]; then
35 # If llpp terminates kill the inotifywait process.