diff options
| author | MineralwaterXu <[email protected]> | 2020-12-01 22:24:45 +0800 |
|---|---|---|
| committer | MineralwaterXu <[email protected]> | 2020-12-01 22:24:45 +0800 |
| commit | b5da5b662ac4516a762d086d03af90f71665f71d (patch) | |
| tree | 93b83037fce0f7b0f756a85be1dad751f9fb37a9 /dwmbar-functions/dwm_cmus.sh | |
| parent | 22ba6040a38c7aadce1100fb9c02c4c120618296 (diff) | |
autostart and dwmstatus
Diffstat (limited to 'dwmbar-functions/dwm_cmus.sh')
| -rwxr-xr-x | dwmbar-functions/dwm_cmus.sh | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/dwmbar-functions/dwm_cmus.sh b/dwmbar-functions/dwm_cmus.sh new file mode 100755 index 0000000..43f6c76 --- /dev/null +++ b/dwmbar-functions/dwm_cmus.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +# A dwm_bar function that shows the current artist, track, position, duration, and status from cmus +# Joe Standring <[email protected]> +# GNU GPLv3 + +# Dependencies: cmus + +dwm_cmus () { + if ps -C cmus > /dev/null; then + ARTIST=$(cmus-remote -Q | grep -a '^tag artist' | awk '{gsub("tag artist ", "");print}') + TRACK=$(cmus-remote -Q | grep -a '^tag title' | awk '{gsub("tag title ", "");print}') + POSITION=$(cmus-remote -Q | grep -a '^position' | awk '{gsub("position ", "");print}') + DURATION=$(cmus-remote -Q | grep -a '^duration' | awk '{gsub("duration ", "");print}') + STATUS=$(cmus-remote -Q | grep -a '^status' | awk '{gsub("status ", "");print}') + SHUFFLE=$(cmus-remote -Q | grep -a '^set shuffle' | awk '{gsub("set shuffle ", "");print}') + + if [ "$IDENTIFIER" = "unicode" ]; then + if [ "$STATUS" = "playing" ]; then + STATUS="▶" + else + STATUS="⏸" + fi + + if [ "$SHUFFLE" = "true" ]; then + SHUFFLE=" 🔀" + else + SHUFFLE="" + fi + else + if [ "$STATUS" = "playing" ]; then + STATUS="PLA" + else + STATUS="PAU" + fi + + if [ "$SHUFFLE" = "true" ]; then + SHUFFLE=" S" + else + SHUFFLE="" + fi + fi + + printf "%s%s %s - %s " "$SEP1" "$STATUS" "$ARTIST" "$TRACK" + printf "%0d:%02d/" $((POSITION%3600/60)) $((POSITION%60)) + printf "%0d:%02d" $((DURATION%3600/60)) $((DURATION%60)) + printf "%s%s\n" "$SHUFFLE" "$SEP2" + fi +} + +dwm_cmus |
