Support multiple workdirs
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
65fdd688bf
commit
58e1b63fb7
20
ufwd
20
ufwd
|
@ -7,7 +7,6 @@ if ! [[ "$XDG_RUNTIME_DIR" ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Defaults
|
# Defaults
|
||||||
cfg_workdir="$XDG_RUNTIME_DIR/ufwd"
|
|
||||||
cfg_scan_delay='30'
|
cfg_scan_delay='30'
|
||||||
|
|
||||||
msg() { printf '%s\n' "$*"; }
|
msg() { printf '%s\n' "$*"; }
|
||||||
|
@ -48,7 +47,8 @@ main() {
|
||||||
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;;
|
(--notify|-n) flag_enable_notifications=1;;
|
||||||
|
@ -67,6 +67,8 @@ main() {
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
[[ $cfg_workdir ]] || cfg_workdir="$XDG_RUNTIME_DIR/ufwd"
|
||||||
|
|
||||||
if (( flag_enable_notifications )); then
|
if (( flag_enable_notifications )); then
|
||||||
if type -P notify-send &>/dev/null; then
|
if type -P notify-send &>/dev/null; then
|
||||||
msg "Found notify-send."
|
msg "Found notify-send."
|
||||||
|
@ -76,12 +78,16 @@ main() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "$cfg_workdir" || return 1
|
for p in "${cfg_workdir[@]}"; do
|
||||||
cd "$cfg_workdir" || return 1
|
[[ -d "$p" ]] || return 1
|
||||||
|
done
|
||||||
|
|
||||||
while read -r dir action path; do
|
printf 'Working in:\n'
|
||||||
upload "$dir$path" "$@" &
|
printf ' - %s\n' "${cfg_workdir[@]}"
|
||||||
done < <( inotifywait -m -e close_write "$cfg_workdir" )
|
|
||||||
|
while read -r d e f; do
|
||||||
|
upload "$d$f" "$@" &
|
||||||
|
done < <( inotifywait -m -e close_write "${cfg_workdir[@]}" )
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user