aboutsummaryrefslogtreecommitdiff
path: root/scripts/.local/bin/personal/musctl
blob: 4437f37c90e269a353c47178d4c4be921d9c5fd9 (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
#!/bin/bash

STATE="$(mpc | grep -o playing)"
NAME="$(basename "$(mpc current)")"

notify() {
    if [[ -n "$STATE" ]]; then
      notify-send "Currently playing" "${NAME%.*}"
    else
      notify-send "MPD is currently paused"
    fi
}

case "$1" in
  "prev")
    mpc -q prev
    playerctl -s previous
    ;;
  "toggle")
    mpc -q toggle
    playerctl -s play-pause
    ;;
  "next")
    mpc -q next
    playerctl -s next
    ;;
  "notify")
    notify
    ;;
  *)
    echo "[ Error ] Unknown command"
    ;;
esac