cfg/.config/i3blocks/load
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
528 B
Python
Executable file

#!/usr/bin/python
import multiprocessing
import os
def load_fmt(load):
cores = multiprocessing.cpu_count()
color = '#ffffff'
if load > cores * 0.5:
color = '#FFD966'
if load > cores * 0.7:
color = '#dd0000'
return '<span color="{}">{:.2f}</span>'.format(color, load)
def main():
load1, load5, load15 = os.getloadavg()
print('\uf085 {}, {}, {}'.format(
load_fmt(load1),
load_fmt(load5),
load_fmt(load15),
))
if __name__ == '__main__':
main()