summaryrefslogtreecommitdiffstats
path: root/bin/watch_incoming.sh
blob: b031461f13537e7b76c5c41085ff2d161c6d6c67 (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 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