summaryrefslogtreecommitdiff
path: root/lib/polybar.nix
diff options
context:
space:
mode:
Diffstat (limited to 'lib/polybar.nix')
-rw-r--r--lib/polybar.nix69
1 files changed, 64 insertions, 5 deletions
diff --git a/lib/polybar.nix b/lib/polybar.nix
index d3d5c3d..8a48d94 100644
--- a/lib/polybar.nix
+++ b/lib/polybar.nix
@@ -45,21 +45,24 @@ in {
separator-foreground = colors.${theme}.highlight;
};
- # Bottom bar: memory, temp, network (stacked above CPU bar)
+ # Bottom bar: memory, disk, network
"bar/bottom" = bar-common // {
bottom = true;
offset-y = "${toString bar-height}pt";
modules-left = [ "mem" ];
- modules-center = [ "temp" ];
+ modules-center = [ "disk" ];
modules-right = [ "network-speed" ];
separator = " │ ";
separator-foreground = colors.${theme}.highlight;
};
- # CPU bar: very bottom, just CPU cores
- "bar/cpu" = bar-common // {
+ # GPU bar: CPU and GPU metrics
+ "bar/gpu" = bar-common // {
bottom = true;
- modules-center = [ "cpu" ];
+ modules-left = [ "cpu" ];
+ modules-right = [ "nvidia-gpu" ];
+ separator = " │ ";
+ separator-foreground = colors.${theme}.highlight;
};
"module/ewmh" = {
@@ -191,6 +194,62 @@ in {
format-disconnected = "";
};
+ "module/disk" = {
+ type = "internal/fs";
+ interval = 30;
+ mount-0 = "/";
+ format-mounted = "<label-mounted>";
+ label-mounted = "DISK %percentage_used%%";
+ label-mounted-foreground = colors.${theme}.yellow;
+ };
+
+ "module/nvidia-gpu" = {
+ type = "custom/script";
+ exec = let
+ script = pkgs.writeShellScript "polybar-nvidia" ''
+ data=$(/run/current-system/sw/bin/nvidia-smi --query-gpu=temperature.gpu,memory.used,memory.total,utilization.gpu --format=csv,noheader,nounits)
+
+ # Parse CSV and trim whitespace
+ temp=$(${pkgs.coreutils}/bin/echo "$data" | ${pkgs.gawk}/bin/awk -F, '{print $1}' | ${pkgs.coreutils}/bin/tr -d ' ')
+ mem_used=$(${pkgs.coreutils}/bin/echo "$data" | ${pkgs.gawk}/bin/awk -F, '{print $2}' | ${pkgs.coreutils}/bin/tr -d ' ')
+ mem_total=$(${pkgs.coreutils}/bin/echo "$data" | ${pkgs.gawk}/bin/awk -F, '{print $3}' | ${pkgs.coreutils}/bin/tr -d ' ')
+ util=$(${pkgs.coreutils}/bin/echo "$data" | ${pkgs.gawk}/bin/awk -F, '{print $4}' | ${pkgs.coreutils}/bin/tr -d ' ')
+
+ # Calculate memory percentage
+ mem_pct=$((mem_used * 100 / mem_total))
+
+ # Temp indicator
+ if [ "$temp" -lt 60 ]; then
+ temp_icon="❄"
+ temp_color="%{F#6fb3c0}"
+ elif [ "$temp" -lt 80 ]; then
+ temp_icon="🌡"
+ temp_color="%{F#c0b24f}"
+ else
+ temp_icon="🔥"
+ temp_color="%{F#ff6f6f}"
+ fi
+
+ # Usage bar
+ bars="▁▂▃▄▅▆▇█"
+ idx=$((util / 13))
+ if [ $idx -gt 7 ]; then idx=7; fi
+ bar="''${bars:$idx:1}"
+
+ if [ "$util" -lt 30 ]; then
+ util_color="%{F#51b04f}"
+ elif [ "$util" -lt 70 ]; then
+ util_color="%{F#c0b24f}"
+ else
+ util_color="%{F#ff6f6f}"
+ fi
+
+ ${pkgs.coreutils}/bin/echo "''${temp_color}''${temp_icon} ''${temp}°C%{F-} │ GPU ''${util}% ''${util_color}''${bar}%{F-} │ MEM ''${mem_pct}%"
+ '';
+ in "${script}";
+ interval = 2;
+ };
+
};
};
}