37 lines
962 B
Bash
Executable File
37 lines
962 B
Bash
Executable File
#!/bin/bash
|
|
|
|
icon_file="/tmp/mpd_cover.jpg"
|
|
backup_file="/home/dqnid/.config/custom_icons/music.png"
|
|
final_icon_route="$icon_file"
|
|
id=5657 # HACK: dirty but works
|
|
|
|
notify() {
|
|
mpc readpicture "$(mpc current -f %file%)" > $icon_file
|
|
song_title=$(mpc current -f %Title%)
|
|
song_artist=$(mpc current -f %albumartist%)
|
|
|
|
# check image
|
|
is_image=$(cat $icon_file | grep volume | grep repeat)
|
|
if [[ ${#is_image} > 0 ]]; then
|
|
final_icon_route="$backup_file"
|
|
else
|
|
final_icon_route="$icon_file"
|
|
fi
|
|
|
|
case $1 in
|
|
"playing")
|
|
notify-send -i $final_icon_route -t 6000 -r $id "Currently playing $song_artist" "$song_title"
|
|
;;
|
|
"paused")
|
|
notify-send -i $final_icon_route -t 6000 -r $id "Player paused" "$song_title"
|
|
;;
|
|
esac
|
|
}
|
|
|
|
|
|
while true; do
|
|
status=$(mpc idle player &>/dev/null && mpc status)
|
|
echo "$status" | grep "\[playing\]" &>/dev/null && notify && notify "playing"
|
|
echo "$status" | grep "\[paused\]" &>/dev/null && notify && notify "paused"
|
|
done
|