I am trying to write a little script which does the following:
- Launch the PDF slideshow viewer impress!ve which can display all PDF files inside a folder page after page in a slideshow.
- Watch the folder for changes (adding or deleting files).
- On change, restart the viewer to pick up the modified folder contents.
- Continue watching the folder for changing.
So far it looks like this:
#!/bin/bash
TESTPATH="/some/path/"
while true; do
inotifywait -m -e create,delete,moved_from -r "$TESTPATH" &&
echo "DEBUG: Event detected!" && pkill -f /usr/bin/impressive || true && impressive -a 10 -w "$TESTPATH*.pdf"
done
However I am stuck with the following issue: Once impressive
has been started for the first time, it is stuck inside this iteration and inotifywait
won’t continue monitoring till impressive isn’t killed by hand. I’d like to jump to the next iteration of the while
loop directly after the launch of impressive
, without waiting for it to exit.
I tried putting a nohup
in front of the impressive
call but it lead to my RAM getting full in a second and my machine freezing…
How can I solve this issue?