Skip to content

Instantly share code, notes, and snippets.

@TBog
Last active Apr 28, 2021
Embed
What would you like to do?
Ideapad 5 15alc05
#!/bin/bash
sudo modprobe acpi_call
get_trick_status() {
echo '\_SB.PCI0.LPC0.EC0.STMD' | sudo tee /proc/acpi/call >/dev/null
local STMD=$(sudo cat /proc/acpi/call | cut -d '' -f1)
echo '\_SB.PCI0.LPC0.EC0.QTMD' | sudo tee /proc/acpi/call >/dev/null
local QTMD=$(sudo cat /proc/acpi/call | cut -d '' -f1)
if [[ "$STMD" == "0x0" ]] && [[ "$QTMD" == "0x0" ]]; then
# Extreme performance
PM='EP'
elif [[ "$QTMD" == "0x1" ]]; then
# Battery saving
PM='BS'
elif [[ "$STMD" == "0x1" ]]; then
# Intelligent cooling
PM='IC'
else
# Error ?
PM='Error'
fi
echo '\_SB.PCI0.LPC0.EC0.FCGM' | sudo tee /proc/acpi/call >/dev/null
RC=$(sudo cat /proc/acpi/call | cut -d '' -f1)
echo '\_SB.PCI0.LPC0.EC0.BTSG' | sudo tee /proc/acpi/call >/dev/null
BC=$(sudo cat /proc/acpi/call | cut -d '' -f1)
}
print_trick_status() {
get_trick_status
[[ $1 ]] || echo -n "1) "
echo -n " Performance mode: "
[[ "$PM" == "EP" ]] && echo "Extreme performance"
[[ "$PM" == "BS" ]] && echo "Battery saving"
[[ "$PM" == "IC" ]] && echo "Intelligent cooling"
[[ $1 ]] || echo -n "2) "
[[ "$RC" == "0x1" ]] && echo -n "[x]" || echo -n "[ ]"
echo -e " Rapid charge"
[[ $1 ]] || echo -n "3) "
[[ "$BC" == "0x1" ]] && echo -n "[x]" || echo -n "[ ]"
echo -e " Battery conservation"
[[ $1 ]] && echo || echo "4) Quit"
}
sbmc_call () {
echo "\_SB.PCI0.LPC0.EC0.VPC0.SBMC $1" | sudo tee /proc/acpi/call >/dev/null
}
print_trick_status true
# Allow user to choose
PS3='Toggle IdeaPad trick:'
options=("Performance mode" "Rapid charge" "Battery conservation" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Performance mode")
echo "toggle between Intelligent Cooling, Extreme Performance and Battery Saving"
if [[ "$PM" == "BS" ]]; then
# Set it to Intelligent Cooling mode
echo '\_SB.PCI0.LPC0.EC0.VPC0.DYTC 0x000FB001' | sudo tee /proc/acpi/call >/dev/null
elif [[ "$PM" == "IC" ]]; then
# Set it to Extreme Performance mode
echo '\_SB.PCI0.LPC0.EC0.VPC0.DYTC 0x0012B001' | sudo tee /proc/acpi/call >/dev/null
else
# Set it to Battery Saving mode
echo '\_SB.PCI0.LPC0.EC0.VPC0.DYTC 0x0013B001' | sudo tee /proc/acpi/call >/dev/null
fi
print_trick_status
;;
"Rapid charge")
#echo "toggle RC"
if [[ "$RC" == "0x1" ]]; then
# turn RC off
sbmc_call '0x08'
else
#turn RC on
sbmc_call '0x07'
#turn BC off
sbmc_call '0x05'
fi
print_trick_status
;;
"Battery conservation")
#echo "toggle BC"
if [[ "$BC" == "0x1" ]]; then
#turn BC off
sbmc_call '0x05'
else
#turn BC on
sbmc_call '0x03'
#turn RC off
sbmc_call '0x08'
fi
print_trick_status
;;
"Quit")
break
;;
*) echo "invalid option $REPLY";;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment