3 . /opt/mqtt-mpd/mqmpd.cfg
 
  10 if [ "$passwd" = "-" ]
 
  13   command="mpc -h $host"
 
  17   command="mpc -h $host -P $passwd"
 
  23 #    current=`mpc -h $host -P $passwd current | sed 's/"/\"/g'`
 
  24 #    volume=`mpc -h $host -P $passwd volume | cut -d: -f2 | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'`
 
  26     mapfile -t array < <( $command )
 
  27     if [ ${#array[@]} = 3 ]
 
  32       status=`echo ${str2[0]} | sed 's/^\[//' | sed 's/\]$//'`
 
  33       current_track_num=`echo ${str2[1]} | cut -d '/' -f 1 | sed 's/^#//'`
 
  34       tracks_in_list=`echo ${str2[1]} | cut -d '/' -f 2`
 
  35       current_pos=`echo ${str2[2]} | cut -d '/' -f 1`
 
  36       track_length=`echo ${str2[2]} | cut -d '/' -f 2`
 
  37       volume=`echo ${str3[1]} | sed 's/%//'`
 
  43       if [ ${#array[@]} = 1 ]
 
  52         volume=`echo ${str3[1]} | sed 's/%//'`
 
  53         if [ "$volume" = "n/a" ]
 
  62         # not responding or error
 
  78     mosquitto_pub -i mqtt-mpd-$id -h $mqhost -p $mqport -t $mqtopic/$host/nowplaying -m "$current" -u $mquser -P $mqpassword
 
  79     mosquitto_pub -i mqtt-mpd-$id -h $mqhost -p $mqport -t $mqtopic/$host/volume -m "$volume" -u $mquser -P $mqpassword
 
  80     mosquitto_pub -i mqtt-mpd-$id -h $mqhost -p $mqport -t $mqtopic/$host/status -m "$status" -u $mquser -P $mqpassword
 
  81     mosquitto_pub -i mqtt-mpd-$id -h $mqhost -p $mqport -t $mqtopic/$host/currentnum -m "$current_track_num" -u $mquser -P $mqpassword
 
  82     mosquitto_pub -i mqtt-mpd-$id -h $mqhost -p $mqport -t $mqtopic/$host/tracks -m "$tracks_in_list" -u $mquser -P $mqpassword
 
  83     mosquitto_pub -i mqtt-mpd-$id -h $mqhost -p $mqport -t $mqtopic/$host/currentpos -m "$current_pos" -u $mquser -P $mqpassword
 
  84     mosquitto_pub -i mqtt-mpd-$id -h $mqhost -p $mqport -t $mqtopic/$host/tracklen -m "$track_length" -u $mquser -P $mqpassword
 
  85     mosquitto_pub -i mqtt-mpd-$id -h $mqhost -p $mqport -t $mqtopic/$host/repeat -m "$repeat" -u $mquser -P $mqpassword
 
  86     mosquitto_pub -i mqtt-mpd-$id -h $mqhost -p $mqport -t $mqtopic/$host/random -m "$random" -u $mquser -P $mqpassword
 
  87     mosquitto_pub -i mqtt-mpd-$id -h $mqhost -p $mqport -t $mqtopic/$host/single -m "$single" -u $mquser -P $mqpassword
 
  88     mosquitto_pub -i mqtt-mpd-$id -h $mqhost -p $mqport -t $mqtopic/$host/consume -m "$consume" -u $mquser -P $mqpassword