fan-profile: route 'auto' menu choice through state file
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+15
-5
@@ -12,17 +12,27 @@ map_profile_to_strategy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if [ "$1" = "--menu" ]; then
|
if [ "$1" = "--menu" ]; then
|
||||||
CHOICE=$(fw-fanctrl print list 2>/dev/null \
|
STRATS=$(fw-fanctrl print list 2>/dev/null | grep "^-" | sed 's/^- //')
|
||||||
| grep "^-" \
|
CHOICE=$(printf 'auto\n%s\n' "$STRATS" \
|
||||||
| sed 's/^- //' \
|
|
||||||
| wofi --dmenu \
|
| wofi --dmenu \
|
||||||
--prompt "Fan Strategy:" \
|
--prompt "Fan Strategy:" \
|
||||||
--width 260 \
|
--width 260 \
|
||||||
--height 300 \
|
--height 320 \
|
||||||
--hide-scroll \
|
--hide-scroll \
|
||||||
--no-actions \
|
--no-actions \
|
||||||
--insensitive)
|
--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
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user