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 | |
parent | 67f8f9a8bf48c393b714afa4cab0da0ee121f155 (diff) | |
download | aur-e5acff6852802ea1d9797295030ab8674a1ca4cf.tar.gz |
add notification facility
-rw-r--r-- | PKGBUILD | 4 | ||||
-rwxr-xr-x | addmag | 24 | ||||
-rw-r--r-- | addmag.desktop | 2 |
3 files changed, 25 insertions, 5 deletions
@@ -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" @@ -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 |