From d9fef1e417dc35d61f5bebccf0b10807baa9ddf4 Mon Sep 17 00:00:00 2001 From: oantoine Date: Mon, 15 Aug 2016 22:32:44 +0200 Subject: AOU:initialisation du projet --- btn_track.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 btn_track.sh (limited to 'btn_track.sh') diff --git a/btn_track.sh b/btn_track.sh new file mode 100644 index 0000000..1deb649 --- /dev/null +++ b/btn_track.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +#Set GPIO ID with push button +GPIO_ID="24" + +#Initialize GPIO +echo $GPIO_ID > /sys/class/gpio/export +echo in > /sys/class/gpio/gpio$GPIO_ID/direction + +#Start MPC +mpc clear +mpc load radios +mpc repeat on +mpc play + +printf "MPC started" + +i=0 +echo "Loop" +while true +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 + + sudo systemctl poweroff + echo "Shutdown..." + break + fi + + echo "Next Track" + /usr/bin/mpc next +done +echo "End loop" \ No newline at end of file -- cgit v1.2.3