pgf wrote: > > Anything would work. I can make it 1 second. I confess it makes me > twitch a little, but 1 second is eons in modern computer clock speed > time. > That was my feeling too. Isn't this the way a daemon works (something like pigpiod that constantly watches for gpio events), or does they all use a different approach, like system events?
pgf wrote: > You go guy! I have no idea what you're talking about. :-) > I found that if the player is switched off in LMS before the script stops squeezelite, the next time the script restarts squeezelite it comes back in the same 'soft off' state. It's a really minor issue, but I prefer that if the DAC is powered up, squeezelite should restart in the 'soft on' state. This is my attempt to do that by sending the appropriate command to LMS. Call it with 'softpower "$NAME" 1', where $NAME is obtained from /usr/local/etc/pcp/pcp.cfg. I'm totally new to the JSON interface, so there may well be more efficient ways to do this. And I suspect my function will go wrong if the player's $NAME has spaces in it, because it will look like more than one argument. Code: -------------------- #======================================================================================== # send JSON command to soft power on/off (1/0) the player #---------------------------------------------------------------------------------------- softpower() { player_name=$1 pwr=$2 #get LMS address and port . /var/www/cgi-bin/pcp-functions LMSIP=$(pcp_lmsip) . /usr/local/etc/pcp/pcp.cfg [ x"" = x"$LMSWEBPORT" ] && LMSPORT=9000 || LMSPORT=$LMSWEBPORT log "LMS address = $LMSIP:$LMSPORT" $logfile # get player's MAC address from the player name player_info=$(busybox wget -q -O- --post-data='{"id":1,"method":"slim.request","params": [ "-", [ "players", "0", "999" ] ]}' --header 'Content-Type: application/json' http://$LMSIP:$LMSPORT/jsonrpc.js) MAC=$(echo $player_info | awk -F "$player_name" '{print $2}' | awk -F playerid '{print $2}' | awk -F \" '{print $3}') # send soft power request to LMS result=$(busybox wget -q -O- --post-data='{"id":1,"method":"slim.request","params": ["'$MAC'",["power",'$pwr']]}' --header 'Content-Type: application/json' http://$LMSIP:$LMSPORT/jsonrpc.js) log "$result" $logfile } -------------------- pgf wrote: > > I'm not sure what a --nostop would do. All I call is "restart" now, not > "stop". If they don't want "restart" either, then... why would they > run this script? The only thing that happens right now when unplugging > the device is a log message. > I realise that didn't make a lot of sense without an explanation that, for me, the obvious missing function is to stop squeezelite when the DAC is powered down - so a '/usr/local/etc/init.d/squeezelite stop' command in the second section of the script. That way, squeezelite will come and go with the DAC. Clearly you personally don't need that function, so you'd be a candidate for the --nostop option, which would prevent any of the commands in the second section from being triggered. ------------------------------------------------------------------------ chill's Profile: http://forums.slimdevices.com/member.php?userid=10839 View this thread: http://forums.slimdevices.com/showthread.php?t=113661 _______________________________________________ unix mailing list unix@lists.slimdevices.com http://lists.slimdevices.com/mailman/listinfo/unix