blob: dfa36f14329dbef0e554d59a30b0794e37e3512b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#!/bin/sh
filter() {
artist_track=""
status_icon=""
modes=""
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
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=""
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 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
if [ -n "$modes" ]; then
echo "$status_icon$artist_track | $modes"
else
echo "$status_icon$artist_track"
fi
else
echo ""
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.
- paused.
- consume mode.
- shuffle mode.
- repeat mode.
- 1 single mode.
- Left click opens rmpc.
- Middle click pauses.
- Scroll changes track.";; # right click, pause/unpause
4) mpc prev | filter ;; # scroll up, previous
5) mpc next | filter ;; # scroll down, next
8) mpc status | filter ; setsid -f "$TERMINAL" -e "$EDITOR" "$0" >/dev/null 2>&1 < /dev/null ;;
*) mpc status | filter ;;
esac
|