mirror of
https://github.com/jtgans/g13gui.git
synced 2025-06-20 00:14:09 -04:00
This cleans things up significantly in the source tree and makes this easier to manage longer term. In the next few commits, we'll migrate the build to CMake in prep for packaging support. - Move bindings into bindings - Move system configs and misc files into etc - Move LCD apps into contrib/ - Move all source files into srcs - Rename helper extensions to match GNU extension naming, fix the #includes as well - Adjust Makefile to be less verbose and more programmatic
48 lines
1.1 KiB
Python
Executable File
48 lines
1.1 KiB
Python
Executable File
#!/usr/bin/python
|
|
|
|
"""
|
|
simple test script to update G13 LCD with temperature values from lm-sensors
|
|
"""
|
|
|
|
import subprocess
|
|
import re
|
|
import time
|
|
|
|
|
|
def doCmd(*cmd):
|
|
# print("cmd = %r" % (cmd,))
|
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
out, err = p.communicate()
|
|
return out #, err
|
|
|
|
|
|
def get_sensors():
|
|
sensor_lines = doCmd('sensors').split('\n')
|
|
print("sensor_lines = %r" % (sensor_lines,))
|
|
temp_re = re.compile(r'''([a-zA-Z])[a-zA-Z s]+([0-9])\:\s*\+([0-9.]+)[\xc2\xb0C]*C.*''')
|
|
|
|
temps = []
|
|
for line in sensor_lines:
|
|
m = temp_re.match(line)
|
|
if m:
|
|
tag, index, value = m.groups()
|
|
print("%s%s = %s" % (tag, index, value))
|
|
# temps.append("%s%s:%s" % (tag, index, value))
|
|
temps.append("%s" % (value,))
|
|
# else:
|
|
# print("failed to match %r" % (line,))
|
|
|
|
with open('/home/jtgans/.local/var/g13d/in', 'w') as p:
|
|
p.write('pos 0 0 \n')
|
|
p.write('out %s\n' % (' '.join(temps)))
|
|
|
|
|
|
def main():
|
|
while True:
|
|
get_sensors()
|
|
time.sleep(1.0)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|