-
Notifications
You must be signed in to change notification settings - Fork 1
/
screensave.py
53 lines (42 loc) · 1.35 KB
/
screensave.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
#!/usr/bin/env python
#screensave.py
import subprocess
import sys
import os
import memcache # sudo apt-get install memcached python-memcache
shared = memcache.Client(['127.0.0.1:11211'], debug=0)
play = shared.get('play')
screensaver = shared.get('screensaver')
if not play:
play = "0"
shared.set('play', play)
if not screensaver:
screensaver = "0"
shared.set('screensaver', screensaver)
parameters = len(sys.argv) # number of parameters including call itself
if parameters < 2:
print("Error: not enough parameters")
print("Usage: ")
print("play: Kodi playing")
print("stop: Kodi stopped")
print("ss_act: Kodi screensaver active")
print("ss_inact: Kodi screensaver inactive")
print("play " + play + " scr " + screensaver)
sys.exit()
parameters = len(sys.argv) # number of parameters including call itself
i = 1
if sys.argv[i] == "play":
play = "1"
elif sys.argv[i] == "stop" : play = "0"
elif sys.argv[i] == "ss_act" : screensaver = "1"
elif sys.argv[i] == "ss_inact" : screensaver = "0"
else:
print("Error: wrong parameters")
sys.exit()
shared.set('play', play)
shared.set('screensaver', screensaver)
if play == "0" and screensaver == "1":
subprocess.call(["/opt/vc/bin/vcgencmd", "display_power", "0"])
if play == "1":
subprocess.call(["/opt/vc/bin/vcgencmd", "display_power", "1"])
print("play " + play + " scr " + screensaver)