Show fan level in i3status
This commit is contained in:
parent
3e4477a333
commit
6915e702cf
17
i3wrapper.py
17
i3wrapper.py
@ -48,11 +48,12 @@ def _backlight(dev_dir='/sys/class/backlight/intel_backlight'):
|
||||
|
||||
|
||||
THINKFAN_CONF = '/etc/thinkfan.conf'
|
||||
ACPI_IBM_FAN = '/proc/acpi/ibm/fan'
|
||||
|
||||
|
||||
@_bit(7)
|
||||
def _hwtemp(conf=THINKFAN_CONF):
|
||||
if not os.path.exists(THINKFAN_CONF):
|
||||
def _hwtemp(conf=THINKFAN_CONF, fan=ACPI_IBM_FAN):
|
||||
if not os.path.exists(conf):
|
||||
return None, None
|
||||
|
||||
temps = []
|
||||
@ -70,13 +71,23 @@ def _hwtemp(conf=THINKFAN_CONF):
|
||||
avg_temp = float(sum(temps)) / len(temps) / 1000.0
|
||||
color = None
|
||||
|
||||
fan_level = 'unset'
|
||||
try:
|
||||
with open(fan) as fan_fp:
|
||||
for line in fan_fp.readlines():
|
||||
if not line.startswith('level:\t\t'):
|
||||
continue
|
||||
fan_level = int(line.replace('level:\t\t', ''))
|
||||
except (OSError, IOError) as exc:
|
||||
sys.stderr.write(str(exc) + '\n')
|
||||
|
||||
if avg_temp > 75:
|
||||
color = '#ff0000'
|
||||
if avg_temp >= 50:
|
||||
color = '#ffaa00'
|
||||
if avg_temp <= 25:
|
||||
color = '#5599ff'
|
||||
return 'T:{:.1f}°C'.format(avg_temp), color
|
||||
return 'T:{:.1f}°C L:{}'.format(avg_temp, fan_level), color
|
||||
|
||||
|
||||
def _print_line(message):
|
||||
|
Loading…
Reference in New Issue
Block a user