notification support
This commit is contained in:
parent
e13f062037
commit
baa483e7cc
25
ufwd
25
ufwd
|
@ -19,9 +19,12 @@ main() {
|
||||||
while (( $# )); do
|
while (( $# )); do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
(--help|-h) usage; return 0;;
|
(--help|-h) usage; return 0;;
|
||||||
|
|
||||||
(--workdir|-d) cfg_workdir="$2"; shift;;
|
(--workdir|-d) cfg_workdir="$2"; shift;;
|
||||||
(--scan-delay|-D) cfg_scan_delay="$2"; shift;;
|
(--scan-delay|-D) cfg_scan_delay="$2"; shift;;
|
||||||
|
|
||||||
|
(--notify|-n) flag_enable_notifications=1;;
|
||||||
|
|
||||||
(--) shift; break;;
|
(--) shift; break;;
|
||||||
(-*)
|
(-*)
|
||||||
err "Unknown key: $1"
|
err "Unknown key: $1"
|
||||||
|
@ -34,6 +37,15 @@ main() {
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if (( flag_enable_notifications )); then
|
||||||
|
if type -P notify-send &>/dev/null; then
|
||||||
|
msg "Found notify-send."
|
||||||
|
else
|
||||||
|
err "notify-send not found in PATH, disabling notifications."
|
||||||
|
flag_enable_notifications=0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p "$cfg_workdir" || {
|
mkdir -p "$cfg_workdir" || {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
@ -44,7 +56,18 @@ main() {
|
||||||
|
|
||||||
while sleep "$cfg_scan_delay"; do
|
while sleep "$cfg_scan_delay"; do
|
||||||
for i in *; do
|
for i in *; do
|
||||||
ufw -R "$i"
|
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
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user