From 1bf216b0c945b272b163591fab25493c08a62008 Mon Sep 17 00:00:00 2001 From: joestandring Date: Sat, 8 Jun 2019 17:27:49 +0000 Subject: [PATCH] Added dwm_transmission --- README.md | 14 +++++++-- bar-functions/dwm_transmission.sh | 48 +++++++++++++++++++++++++++++++ dwm_bar.sh | 3 +- 3 files changed, 61 insertions(+), 4 deletions(-) create mode 100755 bar-functions/dwm_transmission.sh diff --git a/README.md b/README.md index 8fe775e..a3c2125 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ A modular statusbar for DWM - [dwm_network](#dwm_network) - [dwm_vpn](#dwm_vpn) - [dwm_ccurse](#dwm_ccurse) + - [dwm_transmission](#dwm_transmission) - [Installation](#installation) - [Usage](#usage) - [Customizing](#customizing) @@ -95,11 +96,17 @@ Displays the current VPN connection ``` Dependencies: ```NetworkManager-openvpn``` ### dwm_ccurse -Shows the next appointment from calcurse +Displays the next appointment from calcurse ``` [💡 18/04/19 19:00 20:00 Upload dwm_ccurse] ``` Dependencies: ```calcurse``` +### dwm_transmission +Displays the current status of a torrent with transmission-remote +``` +[⏬ archlinux-2019.06.01... | 92% 1min ⬆3.4 ⬇1.5] +``` +Dependencies: ```transmission-remote``` ## Installation 1. Clone and enter the repository: ``` @@ -129,7 +136,7 @@ dwm-bar is completley modular, meaning you can mix and match functions to your h If you want to make your own function, for example dwm_myfunction.sh, you should create it in the functions/ subdirectory before including it in dwm_bar.sh and adding it to the xsetroot command: ``` # Import the modules -. "$DIR/functions/dwm_myfucntion" +. "$DIR/bar-functions/dwm_myfucntion" while true do @@ -143,7 +150,7 @@ You can also decide to use unicode or plaintext identifiers for functions by alt ``` Whereas, if it is not set it will display: ``` -[MAI 0] +[MAIL 0] ``` ## Acknowledgements Code for some functions was modified from: @@ -153,3 +160,4 @@ Code for some functions was modified from: * [suckless.org](https://dwm.suckless.org/status_monitor/) ## More to come! * dwm_bluez function to show currently connected Bluetooth device using bluez +* dwm_mpd diff --git a/bar-functions/dwm_transmission.sh b/bar-functions/dwm_transmission.sh new file mode 100755 index 0000000..ee21b4f --- /dev/null +++ b/bar-functions/dwm_transmission.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# A dwm_bar function to show the status of a torrent woth transmission-remote +# Joe Standring +# GNU GPLv3 + +# Dependencies: transmission-remote + +dwm_transmission () { + TORRENT=$(transmission-remote -l | sed '2q;d' | sed 's/\(.\) /\1/g') + ID=$(printf "%s" "$TORRENT" | awk '{print $1;}') + STATUS=$(printf "%s" "$TORRENT" | awk '{print $8;}') + ETA=$(printf "%s" "$TORRENT" | awk '{print $4;}') + NAME=$(printf "%s" "$TORRENT" | awk '{for(i=9;i<=NF;++i)print $i}' | tr -d "\n" | head -c 20; printf "...") + DONE=$(printf "%s" "$TORRENT" | awk '{print $2;}') + UP=$(printf "%s" "$TORRENT" | awk '{print $5;}') + DOWN=$(printf "%s" "$TORRENT" | awk '{print $5;}') + + if [ "$ID" != "Sum:" ]; then + if [ "$IDENTIFIER" = "unicode" ]; then + case "$STATUS" in + "Idle") + printf "[🛑 %s | %s %s ⬆%s ⬇%s]\n" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN" + ;; + "Seeding") + printf "[🌱 %s | ⬆%s ⬇%s]\n" "$NAME" "$UP" "$DOWN" + ;; + "Downloading") + printf "[⏬ %s | %s %s ⬆%s ⬇%s]\n" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN" + ;; + esac + else + case "$STATUS" in + "Idle") + printf "[IDLE %s | %s %s ⬆%s ⬇%s]\n" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN" + ;; + "Seeding") + printf "[SEEDING %s | ⬆%s ⬇%s]\n" "$NAME" "$UP" "$DOWN" + ;; + "Downloading") + printf "[DOWNLOADING %s | %s %s ⬆%s ⬇%s]\n" "$NAME" "$DONE" "$ETA" "$UP" "$DOWN" + ;; + esac + fi + fi +} + +dwm_transmission diff --git a/dwm_bar.sh b/dwm_bar.sh index 362bb30..a07114b 100755 --- a/dwm_bar.sh +++ b/dwm_bar.sh @@ -19,6 +19,7 @@ export IDENTIFIER="unicode" # Import the modules . "$DIR/bar-functions/dwm_countdown.sh" +. "$DIR/bar-functions/dwm_transmission.sh" . "$DIR/bar-functions/dwm_cmus.sh" . "$DIR/bar-functions/dwm_resources.sh" . "$DIR/bar-functions/dwm_battery.sh" @@ -34,6 +35,6 @@ export IDENTIFIER="unicode" # Update dwm status bar every second while true do - xsetroot -name "$(dwm_countdown)$(dwm_cmus)$(dwm_resources)$(dwm_battery)$(dwm_mail)$(dwm_alsa)$(dwm_weather)$(dwm_vpn)$(dwm_network)$(dwm_keyboard)$(dwm_date)" + xsetroot -name "$(dwm_countdown)$(dwm_transmission)$(dwm_cmus)$(dwm_resources)$(dwm_battery)$(dwm_mail)$(dwm_alsa)$(dwm_weather)$(dwm_vpn)$(dwm_network)$(dwm_keyboard)$(dwm_date)" sleep 1 done