summaryrefslogtreecommitdiffstats
path: root/.local/bin/watch_incoming.sh
blob: 64015a5348ffce80063a341cc7f64dd2be548ab8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bash

#############################################################################
#  back when lowe was a thing, this would autospliff the pdf files I'd put in
#  toPrint_staging  #
##############################################################################


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