commit ea05e205a1315464bb9ebda0ad86493eb844e395 parent f77def5fedb62b3cebac7d42af5fd78541a6d522 Author: JayVii <jayvii[AT]posteo[DOT]de> Date: Sat, 16 Jan 2021 16:54:12 +0100 do not check playerstatus if there are no players Diffstat:
M | sguard/sguard.sh | | | 17 | ++++++++++++----- |
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/sguard/sguard.sh b/sguard/sguard.sh @@ -11,13 +11,20 @@ TIMEOUT=60 function check_player_state { PLAYERS=`list_services` PL_STATUS="" - for pl in $PLAYERS; do - PL_STATUS="$PL_STATUS `get_status $pl`" - done - if [[ -z `echo $PL_STATUS | grep "Playing"` ]]; then + # if there are no active players, return "false" + if [[ ! -z "$PLAYERS" ]]; then echo false else - echo true + # get status of active players + for pl in $PLAYERS; do + PL_STATUS="$PL_STATUS `get_status $pl`" + done + # if active players are playing media, return "true", else "false" + if [[ ! -z `echo $PL_STATUS | grep "Playing"` ]]; then + echo true + else + echo false + fi fi }