#!/usr/bin/env bash TARGET=$HOME/Downloads/toPrint/toPrint_staging PROCESSED=$HOME/Downloads/toPrint/toPrint_ready SPLIFF=$HOME/bin/spliff inotifywait -m -e create -e moved_to --format "%f" "${TARGET}" \ | while read -r FILENAME do THUMB=$(mktemp /tmp/pdf_thumbnail_XXXXXXXXX.png) evince-thumbnailer -s 1024 -l "${TARGET}/${FILENAME}" "${THUMB}" mv "${TARGET}/${FILENAME}" "${PROCESSED}/${FILENAME}" $SPLIFF "${PROCESSED}/${FILENAME}" rm -f "${PROCESSED}/${FILENAME}" dunstify -a "spliff" -I "${THUMB}" "$FILENAME" done