Delete a part of the programming and leave it as its original format and although I pulse several times the T5_DC this does not happen.
I am doing something wrong?
Thank you!!
#!/bin/bash
#Config-Files - Read
source "/opt/music_server/sq_cfg/sq_lms.cfg"
source "/opt/music_server/sq_cfg/sq_t5.cfg"
source "/opt/music_server/sq_cfg/sq_zones.cfg"
source "/opt/music_server/sq_cfg/sq_zones_ext.cfg"
#Variable
timeout="10"
#Player--Config-Files - Read
i="1"
while [ $i -le $SLM_ANZAHL ]
do
#Player-Intern
if [ $i -le "9" ]; then
source "/opt/music_server/sq_cfg/zones/sq_zone_0"$i".cfg"
elif [ $i -ge "10" ]; then
source "/opt/music_server/sq_cfg/zones/sq_zone_"$i".cfg"
fi
i=`expr $i + 1`
done
i="1"
while [ $i -le $SLM_ANZAHL_EXT ]
do
#Player-Extern
if [ $i -le "9" ]; then
source "/opt/music_server/sq_cfg/zones_ext/sq_zone_ext_0"$i".cfg"
elif [ $i -ge "10" ]; then
source "/opt/music_server/sq_cfg/zones/sq_zone_ext_"$i".cfg"
fi
i=`expr $i + 1`
done
#Player-Mac-Address - Read
mac_array_int=()
i=1
while [ $i -le $SLM_ANZAHL ]
do
mac_array_int+=(${SLM_MAC_ADDRESS[$i]})
((i++))
done
mac_array_ext=()
i=1
while [ $i -le $SLM_ANZAHL_EXT ]
do
mac_array_ext+=(${SLM_MAC_ADDRESS_EXT[$i]})
((i++))
done
play_fav(){
count_pl=$(printf "$mac playlist tracks ? \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT | awk '{print $4}')
if [ $count_pl == 1 ];then
output=$(printf "$mac favorites playlist play item_id:$fav \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT)
output=$(printf "$mac playlist index -1 \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT)
else
output=$(printf "$mac favorites playlist play item_id:$fav \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT)
fi
}
#Function Say_Favorite
say_fav(){
for ((i=0; i < ${#mac_array_int[@]}; ++i)); do
if [ "$mac" = "${mac_array_int[$i]}" ]; then
zone_location="int"
zone_index=`echo "scale=0; $i + 1" | bc`
fi
done
for ((i=0; i < ${#mac_array_ext[@]}; ++i)); do
if [ "$mac" = "${mac_array_ext[$i]}" ]; then
zone_location="ext"
zone_index=`echo "scale=0; $i + 1" | bc`
fi
done
if [ "$zone_location" == "int" ]; then
url_zone="&zone=$zone_index&zone_ext=0"
fi
if [ "$zone_location" == "ext" ]; then
url_zone="&zone=0&zone_ext=$zone_index"
fi
output=$(printf "$mac stop \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT)
vol=$(printf "$mac mixer volume ? \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT | awk '{print $4}')
vol=`echo "scale=0; $vol + $T5_SAY_FAV_VOL" | bc`
output_fav=$(awk -F 'text="' '{print $2}' /var/lib/squeezeboxserver/prefs/favorites.opml | cut -d'"' -f1 | sed -e 's/ /+/g')
IFS=$'\n' read -rd '' -a favname <<<"$output_fav"
url="http://$LMS_IP/event/event.php?type=tts&text=${favname[$fav]}$url_zone&vol=$vol&overlay=0"
curl -s -X GET $url > /dev/null
}
#Checki if socat for T5 already active
pid_socat=$(ps -eo pid,command | grep "socat - udp4-listen:$T5_UDP_PORT" | grep -v grep | awk '{print $1}')
if [ "$pid_socat" > "0" ]; then
kill -9 $pid_socat
sleep .2
fi
#Start Loop / Wait for Command
socat - udp4-listen:$T5_UDP_PORT,reuseaddr,fork | while read COMMAND
do
command_arr=()
IFS=' ' read -a command_arr <<< "$COMMAND"
com=${command_arr[0]}
mac=${command_arr[1]}
#Check/Read Fav Files
fav_file="/opt/music_server/sq_fav/$mac"
if [ ! -e $fav_file ]; then
fav=1
echo $fav > $fav_file
elif [ ! -s $fav_file ]; then
fav=1
echo $fav > $fav_file
else
fav=$(cat "$fav_file")
if [ $fav == 0 ];then
fav=1
echo $fav > $fav_file
fi
fi
#Chekc if Player Power is 0/1
playerPower=$(printf "$mac power ?\nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT | awk '{print $3}')
#T2 Single_Click #Play / Volume +
if [ $com == "T2_SC" ]; then
if [ $playerPower == 0 ]; then
count_pl=$(printf "$mac playlist tracks ? \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT | awk '{print $4}')
if [ $count_pl == 0 ]; then
if [ $T5_SAY_FAV = 1 ];then say_fav; fi
play_fav
else
play_fav
fi
fi
if [ $playerPower == 1 ]; then
output=$(printf "$mac mixer volume +$T5_VOLUME_STEP \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT)
fi
fi
#T2 Double_Click #Fav +
if [ $com == "T2_DC" ]; then
if [ $playerPower == 1 ]; then
count=$(printf "$mac favorites items 1\nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT | sed 's/.*3A//' )
fav=`echo "scale=0; $fav + 1" | bc`
if [ $fav -lt $count ];then
if [ $T5_SAY_FAV = 1 ];then say_fav; fi
play_fav
else
fav=1
if [ $T5_SAY_FAV = 1 ];then say_fav; fi
play_fav
fi
echo $fav >$fav_file
fi
fi
#T2 Triple_Click #Fav -
if [ $com == "T2_TC" ]; then
#Fav -
if [ $playerPower == 1 ]; then
count=$(printf "$mac favorites items 1\nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT | sed 's/.*3A//' )
fav=`echo "scale=0; $fav - 1" | bc`
if [ $fav -lt 1 ];then
fav=`echo "scale=0; $count - 1" | bc`
if [ $T5_SAY_FAV = 1 ];then say_fav; fi
play_fav
else
if [ $T5_SAY_FAV = 1 ];then say_fav; fi
play_fav
fi
echo $fav >$fav_file
fi
fi
#T5 Single_Click #Volume -
if [ $com == "T5_SC" ]; then
#Volume +
if [ $playerPower == 1 ]; then
output=$(printf "$mac mixer volume -$T5_VOLUME_STEP \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT)
fi
fi
#T5 Double_Click #Stop
if [ $com == "T5_DC" ]; then
if [ $playerPower == 1 ]; then
output=$(printf "$mac power 0 \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT)
fi
fi
#T5 Triple_Click
#other Commands
#Stop all Players
if [ $com == "STOP_ALL" ]; then
for mac in "${mac_array_int[@]}"
do
output=$(printf "$mac power 0 \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT)
done
for mac in "${mac_array_ext[@]}"
do
output=$(printf "$mac power 0 \nexit\n" | nc -q 1 -w $timeout $LMS_IP $LMS_TELNET_PORT)
done
fi
if [ $com == "SAY_FAV" ]; then
if [ $playerPower == 1 ]; then
say_fav
play_fav
fi
fi
done
Wir verarbeiten personenbezogene Daten über Nutzer unserer Website mithilfe von Cookies und anderen Technologien, um unsere Dienste bereitzustellen, Werbung zu personalisieren und Websiteaktivitäten zu analysieren. Wir können bestimmte Informationen über unsere Nutzer mit unseren Werbe- und Analysepartnern teilen. Weitere Einzelheiten finden Sie in unserer Datenschutzrichtlinie.
Wenn Sie unten auf "Einverstanden" klicken, stimmen Sie unserer Datenschutzrichtlinie und unseren Datenverarbeitungs- und Cookie-Praktiken wie dort beschrieben zu. Sie erkennen außerdem an, dass dieses Forum möglicherweise außerhalb Ihres Landes gehostet wird und Sie der Erhebung, Speicherung und Verarbeitung Ihrer Daten in dem Land, in dem dieses Forum gehostet wird, zustimmen.
Kommentar