3 . /opt/mqtt-mpd/mqmpd.cfg
11 command="mpc -h $host"
15 command="mpc -h $host -P $passwd"
24 # current=`mpc -h $host -P $passwd current | sed 's/"/\"/g'`
25 # volume=`mpc -h $host -P $passwd volume | cut -d: -f2 | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'`
27 mapfile -t array < <( $command )
28 if [ ${#array[@]} = 3 ]
33 status=`echo ${str2[0]} | sed 's/^\[//' | sed 's/\]$//'`
34 current_track_num=`echo ${str2[1]} | cut -d '/' -f 1 | sed 's/^#//'`
35 tracks_in_list=`echo ${str2[1]} | cut -d '/' -f 2`
36 current_pos=`echo ${str2[2]} | cut -d '/' -f 1`
37 track_length=`echo ${str2[2]} | cut -d '/' -f 2`
38 volume=`echo ${str3[1]} | sed 's/%//'`
51 volume=`echo ${str3[1]} | sed 's/%//'`
52 if [ "$volume" = "n/a" ]
62 mosquitto_pub -h $mqhost -p $mqport -t $mqtopic/$host/nowplaying -m "$current" -u $mquser -P $mqpassword
63 mosquitto_pub -h $mqhost -p $mqport -t $mqtopic/$host/volume -m "$volume" -u $mquser -P $mqpassword
64 mosquitto_pub -h $mqhost -p $mqport -t $mqtopic/$host/status -m "$status" -u $mquser -P $mqpassword
65 mosquitto_pub -h $mqhost -p $mqport -t $mqtopic/$host/currentnum -m "$current_track_num" -u $mquser -P $mqpassword
66 mosquitto_pub -h $mqhost -p $mqport -t $mqtopic/$host/tracks -m "$tracks_in_list" -u $mquser -P $mqpassword
67 mosquitto_pub -h $mqhost -p $mqport -t $mqtopic/$host/currentpos -m "$current_pos" -u $mquser -P $mqpassword
68 mosquitto_pub -h $mqhost -p $mqport -t $mqtopic/$host/tracklen -m "$track_length" -u $mquser -P $mqpassword
69 mosquitto_pub -h $mqhost -p $mqport -t $mqtopic/$host/repeat -m "$repeat" -u $mquser -P $mqpassword
70 mosquitto_pub -h $mqhost -p $mqport -t $mqtopic/$host/random -m "$random" -u $mquser -P $mqpassword
71 mosquitto_pub -h $mqhost -p $mqport -t $mqtopic/$host/single -m "$single" -u $mquser -P $mqpassword
72 mosquitto_pub -h $mqhost -p $mqport -t $mqtopic/$host/consume -m "$consume" -u $mquser -P $mqpassword