From 27412fa4eb869a020321913e34f53f3ea0148c0d Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Sat, 9 Mar 2024 01:22:57 -0800 Subject: warn on high cpu/mem usage --- panel.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/panel.py b/panel.py index 0dcfade..fdee772 100755 --- a/panel.py +++ b/panel.py @@ -457,12 +457,18 @@ class ModNetIf(ModInterval): class ModCPU(ModInterval): def refresh(self): percent = psutil.cpu_percent() - self.out = Fmt.labelled('CPU', f'{percent:.0f}%%') + buf = f'{percent:.0f}%%' + if percent > 75: + buf = Fmt.fg('#ff4000', buf) + self.out = Fmt.labelled('CPU', buf) class ModMem(ModInterval): def refresh(self): percent = psutil.virtual_memory().percent - self.out = Fmt.labelled('MEM', f'{percent:.0f}%%') + buf = f'{percent:.0f}%%' + if percent > 75: + buf = Fmt.fg('#ff4000', buf) + self.out = Fmt.labelled('MEM', buf) class ModPWVol(ModInterval): def __init__(self, sink='@DEFAULT_AUDIO_SINK@', step='0.05', limit=None, -- cgit v1.2.3-70-g09d2