Last active
March 9, 2021 14:14
-
-
Save sneetsher/75eeb92e23eb66e5078b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
if [ $UID -ne 0 ] | |
then | |
sudo $0 | |
fi | |
readonly BAT_LIMIT_PATH=/sys/devices/platform/sony-laptop/battery_care_limiter | |
readonly USB_CHARGE_PATH=/sys/devices/platform/sony-laptop/usb_charge | |
readonly FAN_SPEED_PATH=/sys/devices/platform/sony-laptop/fanspeed | |
readonly FAN_FORCED_PATH=/sys/devices/platform/sony-laptop/fan_forced | |
while : | |
do | |
read BAT_LIMIT <$BAT_LIMIT_PATH | |
read USB_CHARGE <$USB_CHARGE_PATH | |
read FAN_SPEED <$FAN_SPEED_PATH | |
read FAN_FORCED <$FAN_FORCED_PATH | |
FORCED=$(test $FAN_FORCED -eq 1 && echo "(Forced exhaust)" || true) | |
CHARGE=$(test $USB_CHARGE -eq 1 && echo "Always" || echo "Only plugged") | |
TITLE="Battery: Max $BAT_LIMIT%\nUSB Charge: $CHARGE\nFan Speed: $((FAN_SPEED*100/64))%$FORCED" | |
RESULT=$(dialog --stdout --no-tags --ok-label "Apply" --cancel-label "Exit" --default-item "B$BAT_LIMIT" --menu "$TITLE" 0 0 0 "B50" "Battery 50%" "B80" "Battery 80%" "B100" "Battery 100%" "U0" "USB Default" "U1" "USB Charge" "NF" "H/W Fan control" "FF" "Forced exhaust") | |
case $RESULT in | |
"B50" ) echo 50 >$BAT_LIMIT_PATH ;; | |
"B80" ) echo 80 >$BAT_LIMIT_PATH ;; | |
"B100" ) echo 100 >$BAT_LIMIT_PATH ;; | |
"U0" ) echo 0 >$USB_CHARGE_PATH ;; | |
"U1" ) echo 1 >$USB_CHARGE_PATH ;; | |
"NF" ) echo 0 >$FAN_FORCED_PATH ;; | |
"FF" ) echo 1 >$FAN_FORCED_PATH ;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment