aboutsummaryrefslogtreecommitdiffstats
path: root/mpdnotify/run
blob: 10ce9e794f0db72128c154b0f8ea150ed322e053 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh
# make sure mpd is running
sv check "$SV/mpd" > /dev/null || exit 1

# set DISPLAY environment variable so notify send doesn't complain
export DISPLAY=:0

[ -f ./conf ] && . ./conf || exit 1

while
  song="$(mpc current --wait)"
  rm -f "$coverartfile" # remove old coverart file

  if [ $coverart -eq 1 ]; then
    ffmpeg -y -i "$musicdir/$(mpc -f %file% | head -1)" "$coverartfile" &
    timeout 3 inotifywait -e close "$coverartfile"
    notify-send -i "$coverartfile" -r $ID "Now playing" "$song"
  else
    notify-send -r $ID "Now playing" "$song"
  fi
do :; done