Commit 091498d8 authored by fuzzle's avatar fuzzle

update mpd_idle - fix issues with naming != location

parent 5eb725f1
......@@ -9,13 +9,14 @@
mpcargs="-h 172.16.0.123"
id="MPD"
mqtttopic="mpd/hc/1/info"
forbidden="\"\|\#\`\$"
while true
do
# wait for any mpd event
mpc idle
# get actual mpd infos
mpddata=$(mpc $mpcargs status |tr -d "\n"|tr -d "\"\|")
mpddata=$(mpc $mpcargs status |tr -d "\n"|tr -d "$forbidden")
# string start with volume means player stopped
if [[ $mpddata == volume* ]]
......@@ -41,10 +42,9 @@ do
else
# we hopefully have a running mpd
[[ "$mpddata" == *"[playing]"* ]] && state="[playing]" || state="[paused]"
location=$(echo $mpddata |egrep -o ".*\[playing\]\ |.*\[paused\]\ ")
location=$(echo $location|sed -e "s#\[playing\]|\[paused\]##g")
Song="$(mpc $mpcargs -q -f %title%)"
[ -z $Song ] && Song="$location"
location=$(mpc $mpcargs -f %file% |head -n1|tr -d "\"\$\|\#\`")
Song=$(echo $mpddata |egrep -o ".*\[playing\]\ |.*\[paused\]\ ")
Song=$(echo $Song|sed -E -e "s#\[playing\]\$|\[paused\]\$##g")
# reduce mpddata to get rid of names
# to have "well" structured data
mpddata=$(echo $mpddata |egrep -o "\[playing\]\ .*|\[paused\]\ .*"|tail -n1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment