From 2a63bab202f5fa6e6adb3b05da1ab13cdab8889f Mon Sep 17 00:00:00 2001 From: oantoine Date: Wed, 17 Aug 2016 10:18:40 +0200 Subject: [PATCH] AOU:optimisation du code (while : , let i++ et message d'info) --- btn_track.sh | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/btn_track.sh b/btn_track.sh index 1deb649..c6a3ce5 100644 --- a/btn_track.sh +++ b/btn_track.sh @@ -16,25 +16,22 @@ mpc play printf "MPC started" i=0 -echo "Loop" -while true +echo "Loop check push" +while : do - echo "Until" - until /bin/grep 1 /sys/class/gpio/gpio$GPIO_ID/value >> /dev/null - do - /bin/sleep .1 - done - echo "End until" - i=$((i+1)) - if [ $i -ge 30 ] - then + until /bin/grep 1 /sys/class/gpio/gpio$GPIO_ID/value >> /dev/null + do + /bin/sleep .1 + done - sudo systemctl poweroff - echo "Shutdown..." - break - fi + let i++ + if [ $i -ge 30 ] + then + printf "Shutdown by button" + sudo systemctl poweroff + break + fi - echo "Next Track" - /usr/bin/mpc next + echo "Next Track" + mpc next done -echo "End loop" \ No newline at end of file