forked from eragefe/pi3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.py
38 lines (31 loc) · 1.04 KB
/
default.py
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
38
import RPi.GPIO as GPIO
import os
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(13, GPIO.OUT)
GPIO.setup(26, GPIO.OUT)
eth = os.popen('ip addr show eth0 | grep "\<inet\>" | awk \'{ print $2 }\' | awk -F "/" \'{ print $1 }\'').read().strip()
wlan = os.popen('ip addr show wlan0 | grep "\<inet\>" | awk \'{ print $2 }\' | awk -F "/" \'{ print $1 }\'').read().strip()
if eth != "":
GPIO.output(13, GPIO.HIGH)
GPIO.output(26, GPIO.LOW)
os.system('aplay /root/ethernet.wav')
if wlan != "":
GPIO.output(13, GPIO.HIGH)
GPIO.output(26, GPIO.LOW)
os.system('aplay /root/wifi.wav')
with open("/boot/input") as file:
contents = file.read()
if "streamer" in contents:
GPIO.output(13, GPIO.HIGH)
GPIO.output(26, GPIO.LOW)
with open("/boot/input") as file:
contents = file.read()
if "coax" in contents:
GPIO.output(13, GPIO.LOW)
GPIO.output(26, GPIO.LOW)
with open("/boot/input") as file:
contents = file.read()
if "opt" in contents:
GPIO.output(26, GPIO.HIGH)
GPIO.output(13, GPIO.LOW)