2015-04-16 21:42:06 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
shopt -s nullglob
|
|
|
|
|
2015-10-13 10:52:26 +00:00
|
|
|
# Defaults for XDG
|
|
|
|
if ! [[ "$XDG_RUNTIME_DIR" ]]; then
|
|
|
|
XDG_RUNTIME_DIR="/run/user/$UID"
|
|
|
|
fi
|
|
|
|
|
2015-04-16 21:42:06 +00:00
|
|
|
# Defaults
|
2015-10-13 10:52:26 +00:00
|
|
|
cfg_workdir="$XDG_RUNTIME_DIR/supd"
|
2015-04-16 21:42:06 +00:00
|
|
|
cfg_scan_delay='30'
|
|
|
|
|
|
|
|
msg() { printf '%s\n' "$*"; }
|
|
|
|
err() { echo "$*" >&2; }
|
|
|
|
|
|
|
|
usage() { echo "No help available."; }
|
|
|
|
|
|
|
|
main() {
|
|
|
|
while (( $# )); do
|
|
|
|
case "$1" in
|
|
|
|
(--help|-h) usage; return 0;;
|
|
|
|
(--workdir|-d) cfg_workdir="$2"; shift;;
|
|
|
|
(--scan-delay|-D) cfg_scan_delay="$2"; shift;;
|
|
|
|
|
|
|
|
(--) shift; break;;
|
|
|
|
(-*)
|
|
|
|
err "Unknown key: $1"
|
|
|
|
usage
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
|
|
|
|
(*) break;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
mkdir -p "$cfg_workdir" || {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
cd "$cfg_workdir" || {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
while sleep "$cfg_scan_delay"; do
|
|
|
|
for i in *; do
|
|
|
|
sup -R "$i"
|
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
main "$@"
|