From 0751102915dd7f4a738c8400abd50f38033de1a1 Mon Sep 17 00:00:00 2001 From: Bernardo Magri Date: Mon, 15 Jun 2026 16:46:45 +0100 Subject: [PATCH] fix(waybar): show the power-profile indicator in the summer themes custom/powerprofile only appeared in the generated bar -- its exec was a writeShellScript store path, which can't go in the summer themes' static whole-swap waybar.jsonc, so summer-day/night were missing it (the DND bell already had parity). Promote powerProfileStatus/Cycle to named writeShellScriptBins on PATH (waybar.nix home.packages) and reference them by bare name, then add custom/powerprofile to both summer waybar.jsonc + their waybar.css. Same pattern as the swaync bell. Co-Authored-By: Claude Opus 4.8 --- docs/ROADMAP.md | 15 ++++++--------- modules/home/waybar.nix | 17 +++++++++++++---- themes/summer-day/waybar.css | 1 + themes/summer-day/waybar.jsonc | 9 ++++++++- themes/summer-night/waybar.css | 1 + themes/summer-night/waybar.jsonc | 9 ++++++++- 6 files changed, 37 insertions(+), 15 deletions(-) diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 72de31e..e7dcb69 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -204,15 +204,12 @@ how to override it. Items marked ✓ are shipped. idle behaviour. - Remaining: a boot-only→event-driven charge-limit re-apply (udev) if a firmware resets the threshold on unplug. - - Remaining: the `custom/powerprofile` Waybar indicator only lands in the - generated config — the summer-day/night whole-swap `waybar.jsonc` don't - show it (the module's exec points at Nix-built script store paths, which - can't go in static JSON). Fix by promoting `powerProfileStatus`/`Cycle` - from `writeShellScript` to named `writeShellScriptBin`s on PATH, then - reference them by bare name from both the generated config and the - whole-swap themes (the same parity the DND bell now has). General - pattern: any new generated-config module needs adding to the whole-swap - themes too. + - ✓ **Waybar parity:** the `custom/powerprofile` indicator now shows in the + summer-day/night whole-swap themes too. `powerProfileStatus`/`Cycle` are + named `writeShellScriptBin`s on PATH (`waybar.nix` home.packages), so the + generated config and the static `waybar.jsonc` both exec them by bare + name (the same parity the DND bell has). General pattern: any new + generated-config module needs adding to the whole-swap themes too. - **Full hardware enablement (beyond nixos-hardware):** nixos-hardware profiles cover *basic* per-model functionality (quirks, drivers), but the *advanced* features of a machine — keyed more on the CPU/GPU generation diff --git a/modules/home/waybar.nix b/modules/home/waybar.nix index 5a670ce..0fd0128 100644 --- a/modules/home/waybar.nix +++ b/modules/home/waybar.nix @@ -17,7 +17,11 @@ let # present) running PPD, so the module hides itself on desktops and # under the TLP backend — no system→home coupling. Speedometer glyphs # (slow/medium/fast) map to power-saver/balanced/performance. - powerProfileStatus = pkgs.writeShellScript "nomarchy-powerprofile-status" '' + # + # Named writeShellScriptBins (put on PATH via home.packages below) rather + # than bare writeShellScript store paths, so the whole-swap themes' static + # waybar.jsonc can exec them by name too — same as the swaync bell. + powerProfileStatus = pkgs.writeShellScriptBin "nomarchy-powerprofile-status" '' case "$(ls /sys/class/power_supply/ 2>/dev/null)" in *BAT*) ;; *) exit 0 ;; esac command -v powerprofilesctl >/dev/null 2>&1 || exit 0 prof=$(powerprofilesctl get 2>/dev/null) || exit 0 @@ -29,7 +33,7 @@ let printf '{"text":"%s","tooltip":"Power profile: %s","class":"%s"}\n' "$icon" "$prof" "$prof" ''; # Cycle to the next profile this machine actually offers (wraps around). - powerProfileCycle = pkgs.writeShellScript "nomarchy-powerprofile-cycle" '' + powerProfileCycle = pkgs.writeShellScriptBin "nomarchy-powerprofile-cycle" '' command -v powerprofilesctl >/dev/null 2>&1 || exit 0 cur=$(powerprofilesctl get 2>/dev/null) || exit 0 avail=$(powerprofilesctl list 2>/dev/null | sed -nE 's/^[* ] ([a-z-]+):$/\1/p') @@ -112,10 +116,10 @@ let }; "custom/powerprofile" = { - exec = "${powerProfileStatus}"; + exec = "nomarchy-powerprofile-status"; return-type = "json"; interval = 5; - on-click = "${powerProfileCycle}"; + on-click = "nomarchy-powerprofile-cycle"; }; # swaync notification bell + Do-Not-Disturb state. `-swb` streams JSON @@ -227,4 +231,9 @@ in else generatedStyle ); }; + + # The power-profile helpers on PATH, so both the generated bar and the + # whole-swap themes' static waybar.jsonc can exec them by name. + home.packages = lib.optionals config.nomarchy.waybar.enable + [ powerProfileStatus powerProfileCycle ]; } diff --git a/themes/summer-day/waybar.css b/themes/summer-day/waybar.css index 61d4414..1b83990 100755 --- a/themes/summer-day/waybar.css +++ b/themes/summer-day/waybar.css @@ -48,6 +48,7 @@ window#waybar { #workspaces, #pulseaudio, #network, +#custom-powerprofile, #battery, #tray, #custom-notification, diff --git a/themes/summer-day/waybar.jsonc b/themes/summer-day/waybar.jsonc index c829654..a5c0fd7 100644 --- a/themes/summer-day/waybar.jsonc +++ b/themes/summer-day/waybar.jsonc @@ -11,7 +11,7 @@ "modules-left": ["custom/launcher", "clock", "clock#date"], "modules-center": ["hyprland/workspaces"], - "modules-right": ["pulseaudio", "network", "battery", "tray", "custom/notification", "custom/powermenu"], + "modules-right": ["pulseaudio", "network", "custom/powerprofile", "battery", "tray", "custom/notification", "custom/powermenu"], "hyprland/workspaces": { "disable-scroll": true, @@ -80,6 +80,13 @@ "tray": { "spacing": 8 }, + "custom/powerprofile": { + "return-type": "json", + "interval": 5, + "exec": "nomarchy-powerprofile-status", + "on-click": "nomarchy-powerprofile-cycle" + }, + "custom/notification": { "format": "{icon}", "return-type": "json", diff --git a/themes/summer-night/waybar.css b/themes/summer-night/waybar.css index 2cc8ddf..6d29cbe 100644 --- a/themes/summer-night/waybar.css +++ b/themes/summer-night/waybar.css @@ -54,6 +54,7 @@ window#waybar { #workspaces, #pulseaudio, #network, +#custom-powerprofile, #idle_inhibitor, #battery, #custom-notification, diff --git a/themes/summer-night/waybar.jsonc b/themes/summer-night/waybar.jsonc index 7699afd..a20e96a 100644 --- a/themes/summer-night/waybar.jsonc +++ b/themes/summer-night/waybar.jsonc @@ -11,7 +11,7 @@ "modules-left": ["custom/nomarchy", "clock", "clock#date"], "modules-center": ["hyprland/workspaces"], - "modules-right": ["idle_inhibitor", "pulseaudio", "network", "battery", "tray", "custom/notification", "custom/powermenu"], + "modules-right": ["idle_inhibitor", "pulseaudio", "network", "custom/powerprofile", "battery", "tray", "custom/notification", "custom/powermenu"], "hyprland/workspaces": { "disable-scroll": true, @@ -87,6 +87,13 @@ "tray": { "spacing": 8 }, + "custom/powerprofile": { + "return-type": "json", + "interval": 5, + "exec": "nomarchy-powerprofile-status", + "on-click": "nomarchy-powerprofile-cycle" + }, + "custom/notification": { "format": "{icon}", "return-type": "json",