aboutsummarylogtreecommitdiffstats
path: root/addmag
diff options
context:
space:
mode:
authoraetherised2021-11-08 16:57:06 -0500
committeraetherised2021-11-08 16:57:06 -0500
commite5acff6852802ea1d9797295030ab8674a1ca4cf (patch)
tree435b54da36830b4e264fd0256a00f2fadef8ffa8 /addmag
parent67f8f9a8bf48c393b714afa4cab0da0ee121f155 (diff)
downloadaur-e5acff6852802ea1d9797295030ab8674a1ca4cf.tar.gz
add notification facility
Diffstat (limited to 'addmag')
-rwxr-xr-xaddmag24
1 files changed, 22 insertions, 2 deletions
diff --git a/addmag b/addmag
index dce9fb1f57e3..90876beb890d 100755
--- a/addmag
+++ b/addmag
@@ -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