diff options
author | aetherised | 2021-11-08 16:57:06 -0500 |
---|---|---|
committer | aetherised | 2021-11-08 16:57:06 -0500 |
commit | e5acff6852802ea1d9797295030ab8674a1ca4cf (patch) | |
tree | 435b54da36830b4e264fd0256a00f2fadef8ffa8 /addmag | |
parent | 67f8f9a8bf48c393b714afa4cab0da0ee121f155 (diff) | |
download | aur-e5acff6852802ea1d9797295030ab8674a1ca4cf.tar.gz |
add notification facility
Diffstat (limited to 'addmag')
-rwxr-xr-x | addmag | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -13,9 +13,23 @@ RCNAME="addmagrc" SYSRC="/etc/${RCNAME}" USRRC="${HOME}/.${RCNAME}" +ADDR= +NOTIFY= + +while getopts 'n' arg; do + case "${arg}" in + n) NOTIFY="true" ;; + *) echo "invalid argument '${arg}'"; exit 1;; + esac +done + +shift $((OPTIND - 1)) LINK="${1}" -ADDR= + +notify() { + notify-send "${@}" || echo "notification failed" +} if [[ -z "${LINK}" ]]; then echo "ERROR: no magnet link or torrent file specified" @@ -32,5 +46,11 @@ if [[ -z "${ADDR}" ]]; then exit 1 fi -transmission-remote "${ADDR}" -a "${LINK}" +if transmission-remote "${ADDR}" -a "${LINK}"; then + echo "added '${LINK}' to '${ADDR}'" + [[ -n "${NOTIFY}" ]] && notify -u normal -t 5000 "TORRENT ADDED" "Added torrent to '${ADDR}'" +else + echo "ERROR: failed to add '${LINK}' to '${ADDR}'" + [[ -n "${NOTIFY}" ]] && notify -u critical -t 5000 "TORRENT ADD FAILED" "Failed to add torrent to '${ADDR}'" +fi |