-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvolumio_com.py
94 lines (83 loc) · 1.91 KB
/
volumio_com.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
import subprocess
import json
def is_play():
str_cmd = ["volumio","status"]
result = subprocess.run(str_cmd,capture_output=True)
ret_play = json.loads(result.stdout)
print(ret_play)
if ret_play['status'] == 'stop':
print("stop")
return False
elif ret_play['status'] == 'play':
print("play")
return True
elif ret_play['status'] == 'pause':
print("pause")
return False
else:
print("non")
return False
def play():
if is_play():
str_cmd = ["volumio","pause"]
else:
str_cmd = ["volumio","play"]
print(str_cmd)
result = subprocess.run(str_cmd)
print('')
def prev():
str_cmd = ["volumio","previous"]
print(str_cmd)
result = subprocess.run(str_cmd)
print('')
def next():
str_cmd = ["volumio","next"]
print(str_cmd)
result = subprocess.run(str_cmd)
print('')
def volup():
str_cmd = ["volumio","volume","plus"]
print(str_cmd)
result = subprocess.run(str_cmd)
print('')
def voldw():
str_cmd = ["volumio","volume","minus"]
print(str_cmd)
result = subprocess.run(str_cmd)
print('')
def voltog():
str_cmd = ["volumio","volume","toggle"]
print(str_cmd)
result = subprocess.run(str_cmd)
print('')
def shutdown():
str_cmd = ["shutdown","-h","now"]
print(str_cmd)
result = subprocess.run(str_cmd)
def main():
print("1:prev")
print("2:volup")
print("3:play")
print("4:voldw")
print("5:next")
print("6:voltog")
print("7:shutdown")
n = input("実行番号を入力してください:")
if n == "1":
prev()
elif n == "2":
volup()
elif n == "3":
play()
elif n == "4":
voldw()
elif n == "5":
next()
elif n == "6":
voltog()
elif n == "7":
shutdown()
else:
print("入力エラー")
if __name__ == '__main__':
main()