Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
47fe62a7c8 | |||
639a97f43e | |||
784ad95215 | |||
58e1b63fb7 | |||
65fdd688bf |
14
ufw
14
ufw
@@ -388,8 +388,18 @@ main() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
case "${action:-upload}" in
|
case "${action:-upload}" in
|
||||||
upload) upload "$1";;
|
upload)
|
||||||
url) get_shortlink "$1";;
|
for t in "$@"; do
|
||||||
|
upload "$t"
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
|
||||||
|
url)
|
||||||
|
for t in "$@"; do
|
||||||
|
get_shortlink "$1"
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
|
||||||
getmyip) get_my_ip;;
|
getmyip) get_my_ip;;
|
||||||
login) login;;
|
login) login;;
|
||||||
esac
|
esac
|
||||||
|
35
ufwd
35
ufwd
@@ -6,10 +6,6 @@ if ! [[ "$XDG_RUNTIME_DIR" ]]; then
|
|||||||
XDG_RUNTIME_DIR="/run/user/$UID"
|
XDG_RUNTIME_DIR="/run/user/$UID"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Defaults
|
|
||||||
cfg_workdir="$XDG_RUNTIME_DIR/ufwd"
|
|
||||||
cfg_scan_delay='30'
|
|
||||||
|
|
||||||
msg() { printf '%s\n' "$*"; }
|
msg() { printf '%s\n' "$*"; }
|
||||||
err() { echo "$*" >&2; }
|
err() { echo "$*" >&2; }
|
||||||
|
|
||||||
@@ -18,7 +14,6 @@ usage() {
|
|||||||
printf ' -h # Show this message.\n'
|
printf ' -h # Show this message.\n'
|
||||||
printf ' -n # Enable notifications with notify-send. Must be installed.\n'
|
printf ' -n # Enable notifications with notify-send. Must be installed.\n'
|
||||||
printf ' -d [path] # Set the dir that is to be watched.\n'
|
printf ' -d [path] # Set the dir that is to be watched.\n'
|
||||||
printf ' -D [sec] # Set the check interval.\n'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
upload() {
|
upload() {
|
||||||
@@ -47,26 +42,20 @@ 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;;
|
|
||||||
(--scan-delay|-D) cfg_scan_delay="$2"; shift;;
|
|
||||||
|
|
||||||
(--notify|-n) flag_enable_notifications=1;;
|
(--notify|-n) flag_enable_notifications=1;;
|
||||||
|
|
||||||
(--clipboard|-c) flag_enable_clipboard=1;;
|
(--clipboard|-c) flag_enable_clipboard=1;;
|
||||||
|
|
||||||
(--) shift; break;;
|
(--workdir|-d) cfg_workdir+=( "$2" ); shift;;
|
||||||
(-*)
|
|
||||||
err "Unknown key: $1"
|
|
||||||
usage
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
|
|
||||||
|
(--) shift; break;;
|
||||||
|
(-*) err "Unknown key: $1"; usage; return 1;;
|
||||||
(*) break;;
|
(*) break;;
|
||||||
esac
|
esac
|
||||||
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 +65,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 create "$cfg_workdir" )
|
|
||||||
|
while read -r d e f; do
|
||||||
|
upload "$d$f" "$@" &
|
||||||
|
done < <( inotifywait -m -e close_write "${cfg_workdir[@]}" )
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
Reference in New Issue
Block a user