Set of scripts for custom power settings and battery conservation. The scripts are made for Lenovo laptops.
Copyright Vaal 2025
This project requires the following tools to be installed on your system:
powerprofilesctlpowertoplogger- Bash shell
You can install them on most distributions with:
sudo apt install powerprofilesctl powertop bsdutils bashNote: These scripts require Bash. Please ensure you are running them with Bash, not sh or another shell.
The script should be running by UDEV, triggering by power adapter connect \ disconnect events. As an bonus option it can change Lenovo Battery conservation mode setting.
Use the provided deployment script to install the power management tools:
sudo ./deploy.sh installThis will install:
- UDEV rule to
/etc/udev/rules.d/99-powersaving.rules - Power management script to
/usr/local/sbin/powerManagement.sh - Symlink
pmto/usr/local/bin/pmfor easy access
After installation, you can run the power management script in two ways:
- Direct execution:
/usr/local/sbin/powerManagement.sh [AC|BAT|CM|CP] - Using symlink:
pm [AC|BAT|CM|CP](available from anywhere in the system)
The script will be automatically triggered by UDEV when power adapter events occur.
pm CM on— Enable Lenovo Battery Conservation Mode.pm CM off— Disable Lenovo Battery Conservation Mode.pm CP— Show current power and battery conservation settings.
sudo ./deploy.sh install- Install power management toolssudo ./deploy.sh tests- Run tests to verify installationsudo ./deploy.sh uninstall- Remove power management toolssudo ./deploy.sh clean- Remove backup files from working directorysudo ./deploy.sh all- Install, test, and clean (GOD Mode)
- desktop notifications. It's complicated for root user, under which udev daemon start the script. It seems you should determine some dbus and session IDs before you can send desktop notification from root.
- add environment zeroing and other best practices for safe start, use shellcheck
- (?) when we're on AC and the battery is reached 75% request a user if they wants to switch to conservation mode this probably require an additional UDEV rule tho
99-powersaving.rules
ACTION=="change", KERNEL=="ACAD", SUBSYSTEM=="power_supply", ATTR{online}=="1", RUN+="/usr/local/sbin/powerManagement.sh AC"
ACTION=="change", KERNEL=="ACAD", SUBSYSTEM=="power_supply", ATTR{online}=="0", RUN+="/usr/local/sbin/powerManagement.sh BAT"