diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2023-07-08 03:39:40 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2023-07-11 13:30:17 +0200 |
| commit | 05a76f289912a7a0cdf3749057c376019fe0b68b (patch) | |
| tree | f8cd7ffae4f1cb614dc0d1419eba4d1a5393bbfc /watchdir | |
| parent | aae26c510dd8a1228848d75c33a07eb992f8dd2a (diff) | |
WIP add thumbnail CLI toolsthumbnail
Diffstat (limited to 'watchdir')
| -rwxr-xr-x | watchdir | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/watchdir b/watchdir new file mode 100755 index 0000000..fe215b2 --- /dev/null +++ b/watchdir @@ -0,0 +1,52 @@ +#! /bin/sh + +usage() +{ + echo "$0 [-s <size>] [-r] [-h] [-d <subdir>] <dir>" +} + +REGEN=0 +SIZE=96 + +while getopts rs:d:h arg +do + case $arg in + r) REGEN=1 + ;; + s) SIZE="$OPTARG" + ;; + h) usage + exit 0 + ;; + d) SUBDIR="$OPTARG" + ;; + ?) usage >&2 + exit 1 + ;; + esac +done + +shift $(($OPTIND - 1)) + +if [ $# != 1 ]; then + usage >&2 + exit 1 +fi + +DIR="$1" + +[ "$REGEN" -eq 1 ] && "$(dirname $0)/tngen" \ + ${SIZE:+-s$SIZE} \ + -d "$DIR" \ + "$DIR/user" + +while : +do + F="$(inotifywait -e modify,move,create,delete \ + --format "%w%f" -qr "$DIR/user/")" + sleep 1 # TODO: revisit this + "$(dirname $0)/tngen" \ + ${SIZE:+-s$SIZE} \ + -d "$DIR" \ + "$F" +done |
