eubnara / troubleshooting

이것저것 공부하다가 맞닥뜨리는 문제점, 해결방식 등 정리
2 stars 0 forks source link

lenovo ideapad battery limit #61

Open eubnara opened 2 years ago

eubnara commented 2 years ago

https://askubuntu.com/questions/385669/lenovo-ideapad-battery-limit

❯ cat battery-limit.sh 
#!/bin/bash

mode_file="/sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode"

if [[ "$#" == "0" ]];then
    status=`cat "$mode_file"`
    if [[ "$status" == "0" ]];then
        echo "off"
    elif [[ "$status" == "1" ]];then
        echo "on"
    else
        echo "Unknown status: $status"
    fi
    exit 0
fi

if [[ "$#" != "1" ]];then
    echo "Usage: $0 [on|off]"
fi

if [[ "$1" == "on" ]];then
    echo 1 | sudo tee "$mode_file" > /dev/null
fi

if [[ "$1" == "off" ]];then
    echo 0 | sudo tee "$mode_file" > /dev/null
fi