summaryrefslogtreecommitdiffstats
path: root/bin/watch_incoming.sh
blob: eed1da048041b25da418a3a6f03be21f99804fa1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/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