From 49889fc2619e28e0f1e7501551d80e3d6619e30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaroslav=20de=20la=20Pe=C3=B1a=20Smirnov?= Date: Sun, 25 Oct 2020 18:04:04 +0300 Subject: Transmission daemon management * Waybar module to display whether transmission-daemon is running * Sway shortcuts for transmission-daemon and its gtk front-end --- dotfiles/.config/sway/config | 2 ++ dotfiles/.config/waybar/config | 10 ++++++++-- dotfiles/.config/waybar/style.css | 6 ++++-- dotfiles/.local/bin/bartorrentstatus | 9 +++++++++ dotfiles/.local/bin/launch-transmission | 9 +++++++++ dotfiles/.local/bin/toggletorrent | 18 ++++++++++++++++++ 6 files changed, 50 insertions(+), 4 deletions(-) create mode 100755 dotfiles/.local/bin/bartorrentstatus create mode 100755 dotfiles/.local/bin/launch-transmission create mode 100755 dotfiles/.local/bin/toggletorrent (limited to 'dotfiles') diff --git a/dotfiles/.config/sway/config b/dotfiles/.config/sway/config index 3be0700..2485be3 100644 --- a/dotfiles/.config/sway/config +++ b/dotfiles/.config/sway/config @@ -185,6 +185,8 @@ bindsym --to-code { $mod+F4 exec menublk $mod+F12 exec menutz $mod+r exec $term -t "ranger" -e ranger + $mod+t exec --no-startup-id toggletorrent + $mod+Ctrl+t exec --no-startup-id launch-transmission $mod+s exec "xway steam" $mod+m exec $term -e ncmpcpp $mod+n exec $term -t "newsboat" -e newsboat && killall -42 waybar diff --git a/dotfiles/.config/waybar/config b/dotfiles/.config/waybar/config index 853d62d..23d2f29 100644 --- a/dotfiles/.config/waybar/config +++ b/dotfiles/.config/waybar/config @@ -1,7 +1,7 @@ { "layer": "bottom", - "height": 27, + "height": 30, "modules-left": [ "sway/workspaces", "sway/mode", @@ -19,6 +19,7 @@ "custom/mail-status", "custom/pac-status", "custom/news-status", + "custom/torrent-status", "custom/vpn-status", "network", "backlight", @@ -174,6 +175,12 @@ "format": "{}", "exec": "barvpnstatus" }, + "custom/torrent-status": { + "format": "{}", + "signal": 10, + "interval": "once", + "exec": "bartorrentstatus" + }, "custom/mail-status": { "format": "📧 {}", "signal": 9, @@ -186,7 +193,6 @@ "signal": 7, "interval": "once", "exec": "barpacstatus", - "tooltip": false }, "custom/news-status": { "format": " {}", diff --git a/dotfiles/.config/waybar/style.css b/dotfiles/.config/waybar/style.css index 077b1f9..3eb4199 100644 --- a/dotfiles/.config/waybar/style.css +++ b/dotfiles/.config/waybar/style.css @@ -37,6 +37,7 @@ window#waybar { #network, #backlight, #custom-vpn-status, +#custom-torrent-status, #workspaces { background: #1d2021; border-top: 2px solid #000000; @@ -72,13 +73,14 @@ window#waybar { #pulseaudio, #temperature, #custom-weather, +#custom-swaykbd, #custom-ds4battery, #custom-rec-status, #custom-vpn-status, -#custom-mail-status, #custom-pac-status, +#custom-mail-status, #custom-news-status, -#custom-swaykbd { +#custom-torrent-status { padding: 0 6px; } #custom-weather { diff --git a/dotfiles/.local/bin/bartorrentstatus b/dotfiles/.local/bin/bartorrentstatus new file mode 100755 index 0000000..637080b --- /dev/null +++ b/dotfiles/.local/bin/bartorrentstatus @@ -0,0 +1,9 @@ +#!/bin/sh + +# TODO: Count how many torrents are downloading and how many are uploading + +if [ -f "$HOME/.cache/transdaemonpid" ] ; then + echo "" +fi + +printf "" diff --git a/dotfiles/.local/bin/launch-transmission b/dotfiles/.local/bin/launch-transmission new file mode 100755 index 0000000..568d12e --- /dev/null +++ b/dotfiles/.local/bin/launch-transmission @@ -0,0 +1,9 @@ +#!/bin/sh + +# Start transmission's remote gtk frontend, if the daemon is not running, then start it as well + +if ! [ -f "$HOME/.cache/transdaemonpid" ] ; then + toggletorrent +fi + +transmission-remote-gtk diff --git a/dotfiles/.local/bin/toggletorrent b/dotfiles/.local/bin/toggletorrent new file mode 100755 index 0000000..4c67cc5 --- /dev/null +++ b/dotfiles/.local/bin/toggletorrent @@ -0,0 +1,18 @@ +#!/bin/sh + +if ! [ -f "$HOME/.cache/transdaemonpid" ] ; then + transmission-daemon + TRANSPID=$! + TRANSEXIT=$? + if [ $TRANSEXIT -eq 0 ]; then + pkill -RTMIN+10 waybar + echo "$TRANSPID" > ~/.cache/transdaemonpid + exit + fi + notify-send " Torrent server" "Error while trying to start Transmission daemon" + exit 1 +fi + +pkill -f "transmission-daemon" +rm ~/.cache/transdaemonpid +pkill -RTMIN+10 waybar -- cgit v1.2.3