summaryrefslogtreecommitdiff
path: root/music
blob: 2ec8aec2e63243773bded4a672279c864d7fb819 (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
#!/sbin/sh

filter() {
    if [ `pgrep -x mpd` ]; then
      MPCSTAT="$(mpc status)" ;
      printf "%s%s%s" "$(echo $MPCSTAT | head -1 | grep -v '^volume' | cut -d'-' -f1 | sed 's/ $//' | cut -c-10)" "$(echo $MPCSTAT | grep -vq '^volume' && echo ' - ')" "$(echo $MPCSTAT | head -1 | grep -v '^volume' | cut -d'-' -f2 | sed 's/^ //' | cut -c-10)"
    fi
}

pidof -x mpdup >/dev/null 2>&1 || mpdup >/dev/null 2>&1 &

case $BLOCK_BUTTON in
    1) mpc status | filter ; setsid -f "$TERMINAL" -e ncmpcpp ;;  # left click, open music player
    3) mpc toggle | filter ;;  # right click, pause/unpause
    2) mpc status | filter ; notify-send "🎵 Music module" "\- Shows mpd song playing.
- Italic when paused.
- Left click opens ncmpcpp.
- Middle click pauses.
- Scroll changes track.";;  # right click, pause/unpause
    4) mpc prev   | filter ;;  # scroll up, previous
    5) mpc next   | filter ;;  # scroll down, next
    6) mpc status | filter ; "$TERMINAL" -e "$EDITOR" "$0" ;;
    *) filter ;;
esac