Created
September 27, 2021 03:04
-
-
Save heisid/5f568c665ba0d93d3833ec4e0078ed3e to your computer and use it in GitHub Desktop.
Battery conservation mode for Ideapad
This file contains 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/sh | |
# A shell script to enable/disable battery conservation mode | |
# in my ideapad gaming 3 laptop | |
# conservation mode is basically a battery charging limiter | |
# to keep the battery within 55-60%. | |
# Good when I plug the charger all the time (which mostly I do) | |
# Not good for traveling | |
# Reference: https://wiki.archlinux.org/title/Laptop/Lenovo#Battery_Conservation_Mode_on_IdeaPad_laptops | |
# | |
# Sid | |
SCRIPT_NAME=$0 | |
print_usage () { | |
echo "Usage: $SCRIPT_NAME on|off|status" | |
} | |
if [ $# -ne 1 ]; then | |
print_usage | |
exit 0 | |
fi | |
CONFIG_FILE="/sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode" | |
STATUS=`cat $CONFIG_FILE` | |
ARG=$1 | |
print_status () { | |
echo -n "Conservation mode is " | |
if [ $STATUS -eq 1 ]; then | |
echo "active." | |
else | |
echo "inactive." | |
fi | |
} | |
write_config () { | |
echo $1 > $CONFIG_FILE | |
} | |
if [ $ARG == "on" ]; then | |
STATUS=1 | |
write_config $STATUS | |
print_status | |
elif [ $ARG == "off" ]; then | |
STATUS=0 | |
write_config $STATUS | |
print_status | |
elif [ $ARG == "status" ]; then | |
print_status | |
else | |
print_usage | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment