3 Commits

Author SHA1 Message Date
fbt
14af6b720f oops
Signed-off-by: fbt <fbt@fleshless.org>
2019-05-09 23:55:03 +03:00
fbt
c22e34afb2 aaaand fork for every file
Signed-off-by: fbt <fbt@fleshless.org>
2019-05-09 23:50:33 +03:00
fbt
d7f1104f82 use inotifywait; clipboard
Signed-off-by: fbt <fbt@fleshless.org>
2019-05-09 23:31:25 +03:00

54
ufwd
View File

@@ -21,6 +21,30 @@ usage() {
printf ' -D [sec] # Set the check interval.\n' printf ' -D [sec] # Set the check interval.\n'
} }
upload() {
declare file=$1
upload_output=$( ufw -R "$@" "$file" )
upload_return=$?
echo "ufw $* -R $file"
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
if (( flag_enable_clipboard )); then
read -r fl <<< "$upload_output"
xclip <<< "$fl"
fi
printf '%s\n' "$upload_output"
}
main() { main() {
while (( $# )); do while (( $# )); do
case "$1" in case "$1" in
@@ -31,6 +55,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,30 +78,12 @@ 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 "$dir$path" &
} done < <( inotifywait -m -e create "$cfg_workdir" )
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
fi
printf '%s\n' "$upload_output"
done
done
} }
main "$@" main "$@"