roxy-docs/inotify.sh
kitsunecafe b040598c56 initial
2024-02-20 06:43:51 -05:00

28 lines
573 B
Bash
Executable file

#!/usr/bin/env bash
if [ -f ".env" ]; then
source .env
if [ -z "$(which inotifywait)" ]; then
echo "inotifywait not installed."
echo "In most distros, it is available in the inotify-tools package."
exit 1
fi
counter=0;
function execute() {
counter=$((counter+1))
echo "Detected change n. $counter"
"$@"
}
echo "watching $WATCH"
inotifywait --recursive --monitor --format "%e %w%f" \
--event modify,move,create,delete $(echo $WATCH) \
| while read changed; do
echo $changed
"$@"
done
fi