From d1eaa837124dcf648a36bc3eb460e4900f24b350 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 20 Aug 2025 08:00:00 +0100 Subject: [PATCH] Add CPU usage percentage --- modules/hosts/t480/dwm/dwmblocks/cpu.nix | 17 +++++++++++++++++ modules/hosts/t480/dwm/dwmblocks/default.nix | 1 + 2 files changed, 18 insertions(+) create mode 100644 modules/hosts/t480/dwm/dwmblocks/cpu.nix diff --git a/modules/hosts/t480/dwm/dwmblocks/cpu.nix b/modules/hosts/t480/dwm/dwmblocks/cpu.nix new file mode 100644 index 00000000..9e4f03fa --- /dev/null +++ b/modules/hosts/t480/dwm/dwmblocks/cpu.nix @@ -0,0 +1,17 @@ +{ + flake.modules.homeManager.gui = + { pkgs, ... }: + { + home.packages = [ + (pkgs.writeShellApplication { + name = "status-cpu"; + + runtimeInputs = with pkgs; [ sysstat ]; + + text = '' + mpstat | grep -A 5 "%idle" | tail -n 1 | awk -F " " '{printf "%s%% CPU", 100 - $ 12}' + ''; + }) + ]; + }; +} diff --git a/modules/hosts/t480/dwm/dwmblocks/default.nix b/modules/hosts/t480/dwm/dwmblocks/default.nix index fa35982e..886c3b3d 100644 --- a/modules/hosts/t480/dwm/dwmblocks/default.nix +++ b/modules/hosts/t480/dwm/dwmblocks/default.nix @@ -14,6 +14,7 @@ {"", "free -h | awk '/^Mem/ { printf \"%s/%s RAM\\n\", $3, $2 }' | sed 's/i//g'", 30, 0}, + {"", "status-cpu", 10, 0}, {"", "date '+%x %R'", 30, 0}, };