diff options
author | awy <awy@awy.one> | 2025-08-06 04:11:48 +0300 |
---|---|---|
committer | awy <awy@awy.one> | 2025-08-06 04:11:48 +0300 |
commit | 1ea75b004d91f6addeb2b89f8934f0c6202bd048 (patch) | |
tree | dad2ad1430b026c987bd248245a4dd1208210faa /.local | |
parent | 7be03d4c0974a5d740d6ee00c63dcf1bb8d0282b (diff) | |
download | hyprdots-1ea75b004d91f6addeb2b89f8934f0c6202bd048.tar.gz |
sb-music update
shows more modes
Diffstat (limited to '.local')
-rwxr-xr-x | .local/bin/statusbar/sb-music | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/.local/bin/statusbar/sb-music b/.local/bin/statusbar/sb-music index 74e7f79..647ed8d 100755 --- a/.local/bin/statusbar/sb-music +++ b/.local/bin/statusbar/sb-music @@ -1,14 +1,70 @@ #!/bin/sh -filter() { sed "/^volume:/d;s/\\[paused\\].*//g;/\\[playing\\].*/d;/^ERROR/Q" | paste -sd ' ' -;} +filter() { + artist_track="" + status_icon="" + modes="" + + # Flag to track if we've captured the artist and track name + track_info_captured=false + + # Read input line by line + while IFS= read -r line; do + # Capture the first line with artist and track name + if [ "$track_info_captured" = false ]; then + artist_track="$line" + track_info_captured=true + continue # Skip processing this line for playback modes + fi + + # Check for track status (paused or playing) + if echo "$line" | grep -q "\[paused\]"; then + status_icon=" " + elif echo "$line" | grep -q "\[playing\]"; then + status_icon="" # Clear status_icon if playing + fi + + # Check for modes: consume, random, repeat, single + if echo "$line" | grep -q "consume: on"; then + modes="${modes} " + fi + if echo "$line" | grep -q "random: on"; then + modes="${modes} " + fi + if echo "$line" | grep -q "repeat: on"; then + modes="${modes} " + fi + if echo "$line" | grep -q "single: on"; then + modes="${modes}1 " + fi + + done + + # After all lines have been processed, output the result + if [ "$track_info_captured" = true ]; then + # Trim the trailing space from modes if any + modes=$(echo "$modes" | sed 's/[[:space:]]*$//') + + # Only add "|" if there are modes + if [ -n "$modes" ]; then + echo "$status_icon$artist_track | $modes" + else + echo "$status_icon$artist_track" + fi + fi +} pidof -x sb-mpdup >/dev/null 2>&1 || sb-mpdup >/dev/null 2>&1 & case $BLOCK_BUTTON in 1) mpc status | filter ; setsid -f "$TERMINAL" -e rmpc >/dev/null 2>&1 < /dev/null;; # right click, pause/unpause 2) mpc toggle | filter ;; # right click, pause/unpause - 3) mpc status | filter ; notify-send "🎵 Music module" "\- Shows mpd song playing. -- ⏸ when paused. + 3) mpc status | filter ; notify-send " Music module" "\- Shows mpd song playing. +- paused. +- consume mode. +- shuffle mode. +- repeat mode. +- 1 single mode. - Left click opens rmpc. - Middle click pauses. - Scroll changes track.";; # right click, pause/unpause |