From 4927db50f51d483b611f0ed42f97e9ac3f6e5de3 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Thu, 2 May 2024 20:20:55 +0200 Subject: add torrent url handler for remote seedbox --- .local/share/applications/addtorrent.desktop | 8 ++++++ .local/share/bin/addtorrent | 41 ++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .local/share/applications/addtorrent.desktop create mode 100755 .local/share/bin/addtorrent diff --git a/.local/share/applications/addtorrent.desktop b/.local/share/applications/addtorrent.desktop new file mode 100644 index 0000000..fe590d6 --- /dev/null +++ b/.local/share/applications/addtorrent.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=addtorrent +Name[ja]=トレントを追加 +Exec=addtorrent %U +Type=Application +Hidden=true +MimeType=application/x-bittorrent;x-scheme-handler/magnet; + diff --git a/.local/share/bin/addtorrent b/.local/share/bin/addtorrent new file mode 100755 index 0000000..bf238d6 --- /dev/null +++ b/.local/share/bin/addtorrent @@ -0,0 +1,41 @@ +#!/bin/sh +progname="$(basename "$0")" + +title="Torrent" +msg_ok="Torrent successfully added" +msg_err="Could not add torrent" +usage="usage: $progname URL" +err_no_seedbox="error: \$SEEDBOX_LOGIN is not set" + +case "$LANG" in + ja_JP*) + title="トレント" + msg_ok="一つのトレントを追加しました" + msg_err="トレントを追加できませんでした" + usage="用法: $progname URL" + err_no_seedbox="エラー: \$SEEDBOX_LOGINに値がありません" + ;; +esac + +die() { + echo "$1" + exit 1 +} + +[ $# -eq 0 ] && die "$usage" +[ -z "$SEEDBOX_LOGIN" ] && die "$err_no_seedbox" + +ssh "$SEEDBOX_LOGIN" transmission-remote -a "'$(echo "$1" | sed "s/'/'\\''/g")'" +if [ $? -eq 0 ]; then + msg="$msg_ok" + urgency="normal" +else + msg="$msg_err" + urgency="critical" +fi + +notify-send \ + --app-name "$title" \ + --urgency "$urgency" \ + "$title" "$msg" + -- cgit v1.2.3