From cc164dfa50bb7657a5979cc721e6f0c684756efb Mon Sep 17 00:00:00 2001 From: funman300 Date: Fri, 1 May 2026 11:24:58 -0700 Subject: [PATCH] fan-profile: route 'auto' menu choice through state file Co-Authored-By: Claude Sonnet 4.6 --- scripts/fan-profile.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/scripts/fan-profile.sh b/scripts/fan-profile.sh index 5786976..fe0fd8b 100755 --- a/scripts/fan-profile.sh +++ b/scripts/fan-profile.sh @@ -12,17 +12,27 @@ map_profile_to_strategy() { } if [ "$1" = "--menu" ]; then - CHOICE=$(fw-fanctrl print list 2>/dev/null \ - | grep "^-" \ - | sed 's/^- //' \ + STRATS=$(fw-fanctrl print list 2>/dev/null | grep "^-" | sed 's/^- //') + CHOICE=$(printf 'auto\n%s\n' "$STRATS" \ | wofi --dmenu \ --prompt "Fan Strategy:" \ --width 260 \ - --height 300 \ + --height 320 \ --hide-scroll \ --no-actions \ --insensitive) - [ -n "$CHOICE" ] && fw-fanctrl use "$CHOICE" && pkill -RTMIN+9 waybar + [ -z "$CHOICE" ] && exit + if [ "$CHOICE" = "auto" ]; then + mkdir -p "$(dirname "$STATE_FILE")" + touch "$STATE_FILE" + PROFILE=$(powerprofilesctl get 2>/dev/null) \ + && MAPPED=$(map_profile_to_strategy "$PROFILE") \ + && fw-fanctrl use "$MAPPED" + else + rm -f "$STATE_FILE" + fw-fanctrl use "$CHOICE" + fi + pkill -RTMIN+9 waybar exit fi