-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharduideck.py
135 lines (99 loc) · 3.19 KB
/
arduideck.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# ----- LIBRARY IMPORTATION -----
import time
import serial
import os
import sys
from pyfiglet import Figlet
# ----- FIGLET -----
f = Figlet(font="slant")
print(f.renderText("ArduiDeck"))
# ----- VARIABLES -----
connected = False
port = open("src/port.txt", "r").read()
# ----- SERIAL -----
while connected == False:
if os.system("ls {} > /dev/null 2>&1".format(port)) == 0:
print("ArduiDeck connected !")
print("")
arduino = serial.Serial(port, 9600, timeout=.1)
time.sleep(0.5)
arduino.write(bytes("i", "utf-8"))
connected = True
else:
connected = False
time.sleep(0.5)
# ----- LOOP -----
while connected == True:
try:
data = arduino.readline()[:-2]
except:
print("")
print("ArduiDeck disconnected !")
print("")
print("---------------")
print("Auto-reconnecting ...")
print("---------------")
print("")
os.execl(sys.executable, sys.executable, *sys.argv)
if data:
data = str(data, "utf-8")
# ----- COMMON APPS -----
if data == "spark":
os.system("open -a arc")
if data == "system_preferences":
os.system("open -a system\ preferences")
if data == "spark":
os.system("open -a spark")
if data == "messages":
os.system("open -a messages")
if data == "music":
os.system("open -a music")
if data == "photos":
os.system("open -a photos")
if data == "reminders":
os.system("open -a reminders")
if data == "calendar":
os.system("open -a calendar")
if data == "discord":
os.system("open -a disccord")
if data == "remarkable":
os.system("open -a remarkable")
# ----- DEV APPS -----
if data == "terminal":
os.system("open -a iterm")
if data == "vscode":
os.system("open -a Visual\ Studio\ Code")
if data == "source_tree":
os.system("open -a sourcetree")
if data == "arduino":
os.system("open -a arduino")
if data == "textmate":
os.system("open -a textmate")
if data == "termius":
os.system("open -a termius")
if data == "postman":
os.system("open -a postman")
if data == "devdocs":
os.system("open -a devdocs")
if data == "diskutility":
os.system("open -a Disk\ Utility")
if data == "resmon":
os.system("open -a Activity\ Monitor")
# ----- SCRIPTS -----
if data == "speedtest":
print("")
os.system("./src/scripts/speedtest-cli")
print("")
if data == "myip":
print("")
os.system("curl http://ipecho.net/plain; echo")
print("")
if data == "clear":
os.system("clear")
print(f.renderText("ArduiDeck"))
if data == "lock":
os.system("osascript src/scripts/lock.applescript")
if data == "disconnect":
print("")
print("ArduiDeck disconnected !")
os.system("killall Terminal")