diff --git a/hm/desktop/frobar/frobar/__init__.py b/hm/desktop/frobar/frobar/__init__.py index 23764fb..4f22cf1 100644 --- a/hm/desktop/frobar/frobar/__init__.py +++ b/hm/desktop/frobar/frobar/__init__.py @@ -39,6 +39,7 @@ def run(): DANGER_THEME = 1 CRITICAL_THEME = 0 Bar.addSectionAll(CpuProvider(), BarGroupType.RIGHT) + Bar.addSectionAll(LoadProvider(), BarGroupType.RIGHT) Bar.addSectionAll(RamProvider(), BarGroupType.RIGHT) Bar.addSectionAll(TemperatureProvider(), BarGroupType.RIGHT) Bar.addSectionAll(BatteryProvider(), BarGroupType.RIGHT) diff --git a/hm/desktop/frobar/frobar/providers.py b/hm/desktop/frobar/frobar/providers.py index 9568936..2431c7d 100644 --- a/hm/desktop/frobar/frobar/providers.py +++ b/hm/desktop/frobar/frobar/providers.py @@ -92,7 +92,7 @@ class AlertingSection(StatefulSection): class CpuProvider(AlertingSection, PeriodicUpdater): NUMBER_STATES = 3 - ICON = "" + ICON = "" def fetcher(self): percent = psutil.cpu_percent(percpu=False) @@ -108,6 +108,24 @@ class CpuProvider(AlertingSection, PeriodicUpdater): PeriodicUpdater.__init__(self) self.changeInterval(1) +class LoadProvider(AlertingSection, PeriodicUpdater): + NUMBER_STATES = 3 + ICON = "" + + def fetcher(self): + load = os.getloadavg() + self.updateLevel(load[0]) + if self.state >= 2: + return " ".join(f"{load[i]:.2f}" for i in range(3)) + elif self.state >= 1: + return f"{load[0]:.2f}" + + def __init__(self, theme=None): + AlertingSection.__init__(self, theme) + PeriodicUpdater.__init__(self) + self.changeInterval(5) + self.warningThresold = 5 + self.dangerThresold = 10 class RamProvider(AlertingSection, PeriodicUpdater): """ @@ -115,7 +133,7 @@ class RamProvider(AlertingSection, PeriodicUpdater): """ NUMBER_STATES = 4 - ICON = "" + ICON = "" def fetcher(self): mem = psutil.virtual_memory() diff --git a/hm/prompt/default.nix b/hm/prompt/default.nix index 8c81ffd..294eb1b 100644 --- a/hm/prompt/default.nix +++ b/hm/prompt/default.nix @@ -4,7 +4,7 @@ programs.powerline-go = { enable = true; modules = [ "user" "host" "venv" "cwd" "perms" "nix-shell" "git" ]; - modulesRight = [ "jobs" "exit" "duration" "load" ]; + modulesRight = [ "jobs" "exit" "duration" ]; settings = { colorize-hostname = true; hostname-only-if-ssh = true; @@ -20,4 +20,3 @@ }; }; } -# TODO Replace load with a frobar indicator