use inotifywait; clipboard

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2019-05-09 23:31:25 +03:00
parent e2c6143c8c
commit d7f1104f82

24
ufwd
View File

@ -31,6 +31,8 @@ main() {
(--notify|-n) flag_enable_notifications=1;; (--notify|-n) flag_enable_notifications=1;;
(--clipboard|-c) flag_enable_clipboard=1;;
(--) shift; break;; (--) shift; break;;
(-*) (-*)
err "Unknown key: $1" err "Unknown key: $1"
@ -52,17 +54,11 @@ main() {
fi fi
fi fi
mkdir -p "$cfg_workdir" || { mkdir -p "$cfg_workdir" || return 1
return 1 cd "$cfg_workdir" || return 1
}
cd "$cfg_workdir" || { while read -r dir action path; do
return 1 upload_output=$( ufw "$@" -R "$dir$path" )
}
while sleep "$cfg_scan_delay"; do
for i in *; do
upload_output=$( ufw "$@" -R "$i" )
upload_return=$? upload_return=$?
if (( flag_enable_notifications )); then if (( flag_enable_notifications )); then
@ -73,9 +69,13 @@ main() {
fi fi
fi fi
if (( flag_enable_clipboard )); then
read -r fl <<< "$upload_output"
xclip <<< "$fl"
fi
printf '%s\n' "$upload_output" printf '%s\n' "$upload_output"
done done < <( inotifywait -m -e create "$cfg_workdir" )
done
} }
main "$@" main "$@"