summaryrefslogtreecommitdiff
path: root/btn_track_pi1.sh
blob: c6a3ce56d4cdb73e2ed01e2fa73267c77eb923ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/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 check push"
while :
do
    until /bin/grep 1 /sys/class/gpio/gpio$GPIO_ID/value >> /dev/null
    do
        /bin/sleep .1
    done

    let i++
    if [ $i -ge 30 ]
        then
        printf "Shutdown by button"
        sudo systemctl poweroff
        break
    fi

    echo "Next Track"
    mpc next
done