Commit 8d6e66e73f19

Vincent Demeester <vincent@sbr.pm>
2026-07-30 09:37:19
feat: add tuned power profile indicator to waybar
Shows current tuned profile with color-coded icon. Click to cycle through powersave, balanced-battery, balanced, and throughput-performance profiles.
1 parent 5d8b1bf
Changed files (1)
home
common
desktop
home/common/desktop/niri/waybar.nix
@@ -24,6 +24,8 @@
           "custom/separator"
           "wireplumber"
           "custom/separator"
+          "custom/tuned"
+          "custom/separator"
           "battery"
         ];
         "custom/separator" = {
@@ -106,6 +108,35 @@
             "(.*) - zsh" = "> [$1]";
           };
         };
+        "custom/tuned" = {
+          "exec" = pkgs.writeShellScript "waybar-tuned" ''
+            while true; do
+              profile=$(tuned-adm active 2>/dev/null | sed 's/.*: //')
+              case "$profile" in
+                powersave)          icon="๐Ÿ”‹"; class="powersave" ;;
+                balanced-battery)   icon="๐Ÿ”‹"; class="balanced-battery" ;;
+                balanced)           icon="โšก"; class="balanced" ;;
+                throughput-*|performance*) icon="๐Ÿš€"; class="performance" ;;
+                *)                  icon="โš™"; class="unknown" ;;
+              esac
+              printf '{"text": "%s %s", "tooltip": "Power: %s", "class": "%s"}\n' "$icon" "$profile" "$profile" "$class"
+              sleep 10
+            done
+          '';
+          "return-type" = "json";
+          "format" = "{}";
+          "tooltip" = true;
+          "on-click" = pkgs.writeShellScript "tuned-cycle" ''
+            current=$(tuned-adm active 2>/dev/null | sed 's/.*: //')
+            case "$current" in
+              powersave)        next="balanced-battery" ;;
+              balanced-battery) next="balanced" ;;
+              balanced)         next="throughput-performance" ;;
+              *)                next="powersave" ;;
+            esac
+            tuned-adm profile "$next"
+          '';
+        };
         "niri/language" = {
           "format" = "{short}-{variant}";
           "on-click-right" = "niri msg action switch-layout prev";
@@ -237,6 +268,22 @@
         color: #8e24aa; /* Accessible purple for white backgrounds */ /* Mauve in Catppuccin */
       }
 
+      #custom-tuned.powersave {
+        color: #50fa7b;
+      }
+
+      #custom-tuned.balanced-battery {
+        color: #8be9fd;
+      }
+
+      #custom-tuned.balanced {
+        color: #f1fa8c;
+      }
+
+      #custom-tuned.performance {
+        color: #ff5555;
+      }
+
       #custom-separator {
         margin: 0 1px;
       }