From 9ff11905490f5570583edbf326b4162eee732879 Mon Sep 17 00:00:00 2001 From: funman300 Date: Fri, 1 May 2026 11:29:56 -0700 Subject: [PATCH] fan-profile: render auto mode and reconcile fw-fanctrl on poll Co-Authored-By: Claude Sonnet 4.6 --- scripts/fan-profile.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/fan-profile.sh b/scripts/fan-profile.sh index fe0fd8b..c0308ab 100755 --- a/scripts/fan-profile.sh +++ b/scripts/fan-profile.sh @@ -36,6 +36,19 @@ if [ "$1" = "--menu" ]; then exit fi +if [ -f "$STATE_FILE" ]; then + PROFILE=$(powerprofilesctl get 2>/dev/null) + MAPPED=$(map_profile_to_strategy "$PROFILE" 2>/dev/null) + if [ -n "$MAPPED" ]; then + ACTIVE=$(fw-fanctrl print 2>/dev/null | awk -F"'" '/^Strategy:/{print $2}') + [ "$ACTIVE" != "$MAPPED" ] && fw-fanctrl use "$MAPPED" >/dev/null 2>&1 + printf '{"text": "󰈐 auto", "tooltip": "Auto fan strategy\\nProfile: %s → %s\\nClick to change", "class": "auto"}\n' "$PROFILE" "$MAPPED" + else + printf '{"text": "󰈐 auto (?)", "tooltip": "Auto: power-profiles-daemon unreachable or unknown profile\\nClick to change", "class": "auto"}\n' + fi + exit +fi + OUTPUT=$(fw-fanctrl print 2>/dev/null) CURRENT=$(echo "$OUTPUT" | awk -F"'" '/^Strategy:/{print $2}') SPEED=$(echo "$OUTPUT" | awk '/^Speed:/{print $2}')