summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2024-03-09 01:22:57 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2024-03-09 01:22:57 -0800
commit27412fa4eb869a020321913e34f53f3ea0148c0d (patch)
treeda44a7c7ee10309847d7dce48610a7dce8c022a7
parent67efb32979524fb5b5f3764ef058e40274bb5947 (diff)
downloadpanel-27412fa4eb869a020321913e34f53f3ea0148c0d.tar.gz
panel-27412fa4eb869a020321913e34f53f3ea0148c0d.tar.xz
warn on high cpu/mem usageHEADmaster
-rwxr-xr-xpanel.py10
1 files 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,