cfg/.config/i3blocks/temp
Knut Ahlers 4ae353dc51
Bring more color to the i3bar
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2018-12-03 15:22:12 +01:00

31 lines
588 B
Python
Executable file

#!/usr/bin/env python
import re
import subprocess
CRIT = 70.0
def main():
sensors = subprocess.check_output(['sensors', '-u']).decode('utf-8')
max_temp = 0.0
for line in sensors.split('\n'):
if not re.match(r'.*temp._input:.*', line):
continue
temp = float(line.split(':')[1])
if temp > max_temp:
max_temp = temp
color = '#ffffff'
if max_temp > CRIT:
color = '#dd0000'
text = '\uf2c7 <span color="{}">{:.1f}°C</span>'.format(color, max_temp)
print(text)
if __name__ == '__main__':
main()