Hi,

i finaly changed the script

a known "bug" is - if the player is paused it will also powered off
May i have some time to work this out

I added some handling to ignore -non- squeezelite Players as well as
designed the logfile

Since the script simple powers the not playing player off - there is no
need to use another script on a player.
Means only if the LMS based Computer is a *ux System:p


Code:
--------------------
    
  #!/bin/bash
  ## check if any player is playing
  ## and restart squeezelite if timetoplay is equal on both checks
  
  ##vars
  port=9090
  server=localhost
  #use a fresh logfile
  echo "$(date)">/tmp/playercheck.log
  sensors|grep 'Core 0' |awk '{print $3}'|cut -b2,3,4,5,7>>/tmp/playercheck.log
  
  # get number of known players
  players=$(printf "player count ?\nexit\n" | nc $server $port | cut -d ' ' -f 
3)
  echo There are $players known Players>>/tmp/playercheck.log
  
  ## check all known players
  for((i=0; i<$players; i++))
  do
  echo >>/tmp/playercheck.log
  echo checking Player Nr. $i>>/tmp/playercheck.log
  playerID=$(printf "player id $i ?\nexit\n" | nc $server $port | cut -d ' ' -f 
4 | sed 's/%/%%/g')
  playermodel=$(printf "player model $i ? \nexit\n" | nc 127.0.0.1 9090 |cut -d 
' ' -f 3)
  if [ !$playermodel = squeezelite ]
  then
  echo Player Nr. $i is not a squeezelite session>>/tmp/playercheck.log
  else
  playername=$(printf "$playerID name ?\nexit\n" | nc $server $port | cut -d ' 
' -f 3)
  timetoplay1=$(printf "$playerID time ?\nexit\n" | nc $server $port | cut -d ' 
' -f 3)
  echo >>/tmp/playercheck.log
  echo Player $playername>>/tmp/playercheck.log
  echo "          remaining Playtime is $timetoplay1">>/tmp/playercheck.log
  timetoplay2=$(printf "$playerID time ?\nexit\n" | nc $server $port | cut -d ' 
' -f 3)
  echo "          remaining Playtime is $timetoplay2">>/tmp/playercheck.log
  if [ $timetoplay1 = $timetoplay2 ]
  then
  echo no difference between 1st and 2.nd check
  echo "          Player $playername seems not to play right 
now">>/tmp/playercheck.log
  timetoplay3=$(printf "$playerID time ?\nexit\n" | nc $server $port | cut -d ' 
' -f 3)
  if [ $timetoplay1 = $timetoplay3 ]
  then
  printf "$playerID power 0 \nexit\n" | nc $server $port
  fi
  else
  echo "          Player $playername is playing nothing 2do 
4me">>/tmp/playercheck.log
  fi
  fi
  done
  
--------------------



Have Fun



Gruss

Jan
------------------------------------------------------------------------
DJanGo's Profile: http://forums.slimdevices.com/member.php?userid=1516
View this thread: http://forums.slimdevices.com/showthread.php?t=99916

_______________________________________________
unix mailing list
unix@lists.slimdevices.com
http://lists.slimdevices.com/mailman/listinfo/unix

Reply via email to