-
Notifications
You must be signed in to change notification settings - Fork 0
/
wallhackctl.py
77 lines (59 loc) · 2.14 KB
/
wallhackctl.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
#!/usr/bin/env python
#
# ----------------------------------------------------------------------------
# "THE CLUB-MATE LICENSE" (Revision 23.5):
# Some guys from the c3pb.de wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If you meet one of us some day, and you think
# this stuff is worth it, you can buy them a club-mate in return.
# ----------------------------------------------------------------------------
#
import os
import cherrypy
import ConfigParser
import subprocess
from jinja2 import Environment, PackageLoader
env = Environment(loader=PackageLoader('wallhackctl', 'templates'))
links=[]
class Root(object):
@cherrypy.expose
def index(self, s=None):
if s:
try:
x = int(s)
if x in range (0,5):
print "show: %s" % (s)
showScreen (s)
except:
# 'source' does not represent an integer
print "incorrect value for s"
pass
template = env.get_template('index.html')
return template.render(title='CTL', links=links)
def showScreen(x):
screen = "XK_%s" % (x)
subprocess.check_call(["/home/chaos/wallhackctl/xfk", "+XK_Meta_L", screen, "-XK_Meta_L"])
def main():
# Some global configuration; note that this could be moved into a
# configuration file
cherrypy.config.update({
'server.socket_port' : 80,
'server.socket_host' : "0.0.0.0",
'tools.encode.on': True, 'tools.encode.encoding': 'utf-8',
'tools.decode.on': True,
'tools.trailing_slash.on': True,
'tools.staticdir.root': os.path.abspath(os.path.dirname(__file__)),
})
rootconf = {
'/static': {
'tools.staticdir.on': True,
'tools.staticdir.dir': 'static'
}
}
links.append('<a href="?s=1">Clock</a>')
links.append('<a href="?s=2">Slideshow</a>')
links.append('<a href="?s=3">3</a>')
cherrypy.tree.mount(Root(),"/",rootconf)
cherrypy.engine.start()
cherrypy.engine.block()
if __name__ == '__main__':
main()