Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
488fdc0a5a | |||
14af6b720f | |||
c22e34afb2 |
40
ufwd
40
ufwd
@@ -21,6 +21,28 @@ usage() {
|
|||||||
printf ' -D [sec] # Set the check interval.\n'
|
printf ' -D [sec] # Set the check interval.\n'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
upload() {
|
||||||
|
declare file=$1; shift
|
||||||
|
|
||||||
|
upload_output=$( ufw -R "$@" "$file" )
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
@@ -58,23 +80,7 @@ main() {
|
|||||||
cd "$cfg_workdir" || return 1
|
cd "$cfg_workdir" || return 1
|
||||||
|
|
||||||
while read -r dir action path; do
|
while read -r dir action path; do
|
||||||
upload_output=$( ufw "$@" -R "$dir$path" )
|
upload "$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
|
|
||||||
|
|
||||||
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" )
|
done < <( inotifywait -m -e create "$cfg_workdir" )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user