Browse Source

Support multiple workdirs

Signed-off-by: fbt <fbt@fleshless.org>
master
Jack L. Frost 3 years ago
parent
commit
58e1b63fb7
  1. 20
      ufwd

20
ufwd

@ -7,7 +7,6 @@ if ! [[ "$XDG_RUNTIME_DIR" ]]; then
fi
# Defaults
cfg_workdir="$XDG_RUNTIME_DIR/ufwd"
cfg_scan_delay='30'
msg() { printf '%s\n' "$*"; }
@ -48,7 +47,8 @@ main() {
case "$1" in
(--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;;
(--notify|-n) flag_enable_notifications=1;;
@ -67,6 +67,8 @@ main() {
shift
done
[[ $cfg_workdir ]] || cfg_workdir="$XDG_RUNTIME_DIR/ufwd"
if (( flag_enable_notifications )); then
if type -P notify-send &>/dev/null; then
msg "Found notify-send."
@ -76,12 +78,16 @@ main() {
fi
fi
mkdir -p "$cfg_workdir" || return 1
cd "$cfg_workdir" || return 1
for p in "${cfg_workdir[@]}"; do
[[ -d "$p" ]] || return 1
done
printf 'Working in:\n'
printf ' - %s\n' "${cfg_workdir[@]}"
while read -r dir action path; do
upload "$dir$path" "$@" &
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 "$@"

Loading…
Cancel
Save