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