aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/statusbar/sb-music
diff options
context:
space:
mode:
authorawy <awy@awy.one>2025-08-07 04:38:05 +0300
committerawy <awy@awy.one>2025-08-07 04:38:05 +0300
commit82307a7d73dc2683062e1029b98bf976fb50ee26 (patch)
treed3881c27a086f4210ebd3d463391ae21b27af4ad /.local/bin/statusbar/sb-music
parent500d06abcd465c606c9503fc883a63f3a48028f7 (diff)
downloadhyprdots-82307a7d73dc2683062e1029b98bf976fb50ee26.tar.gz
music module update
Diffstat (limited to '.local/bin/statusbar/sb-music')
-rwxr-xr-x.local/bin/statusbar/sb-music21
1 files changed, 13 insertions, 8 deletions
diff --git a/.local/bin/statusbar/sb-music b/.local/bin/statusbar/sb-music
index 647ed8d..dfa36f1 100755
--- a/.local/bin/statusbar/sb-music
+++ b/.local/bin/statusbar/sb-music
@@ -4,24 +4,28 @@ 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
+ # Check if the line contains typical status info (e.g., "volume:") instead of artist-track
+ if echo "$line" | grep -q "volume:"; then
+ # No song is playing, exit with empty output
+ echo ""
+ return
+ fi
artist_track="$line"
track_info_captured=true
- continue # Skip processing this line for playback modes
+ continue
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
+ status_icon=""
fi
# Check for modes: consume, random, repeat, single
@@ -37,12 +41,11 @@ filter() {
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
+ # After all lines processed, output the result only if artist_track is valid
+ if [ "$track_info_captured" = true ] && [ -n "$artist_track" ]; then
+ # Trim trailing space from modes if any
modes=$(echo "$modes" | sed 's/[[:space:]]*$//')
# Only add "|" if there are modes
@@ -51,6 +54,8 @@ filter() {
else
echo "$status_icon$artist_track"
fi
+ else
+ echo ""
fi
}