aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authoraetherised2021-11-08 16:57:06 -0500
committeraetherised2021-11-08 16:57:06 -0500
commite5acff6852802ea1d9797295030ab8674a1ca4cf (patch)
tree435b54da36830b4e264fd0256a00f2fadef8ffa8
parent67f8f9a8bf48c393b714afa4cab0da0ee121f155 (diff)
downloadaur-e5acff6852802ea1d9797295030ab8674a1ca4cf.tar.gz
add notification facility
-rw-r--r--PKGBUILD4
-rwxr-xr-xaddmag24
-rw-r--r--addmag.desktop2
3 files changed, 25 insertions, 5 deletions
diff --git a/PKGBUILD b/PKGBUILD
index 4b260c7903a8..d03853bc87e2 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,8 +1,8 @@
# Maintainer: aetherised <aetherised@gmail.com>
pkgname=addmag
-pkgver=0.1.1
-pkgrel=4
+pkgver=0.2.0
+pkgrel=1
pkgdesc="Opens magnet links using a remote Transmission daemon"
arch=('any')
url="https://github.com/aetherised/addmag"
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
diff --git a/addmag.desktop b/addmag.desktop
index 698616d040fb..f56b3fbcc7b6 100644
--- a/addmag.desktop
+++ b/addmag.desktop
@@ -2,7 +2,7 @@
Name=addmag
GenericName=Transmission Daemon Magnet Link Handler
Comment=Open magnent links with a remote Transmission daemon
-Exec=addmag %U
+Exec=addmag -n %U
Terminal=false
TryExec=addmag
Type=Application