Never forget to charge your laptop again. Or still forget, but at least this script tried to warn you.
batAlert is a lightweight bash script designed to run in the background as a cron job. It monitors your battery level and pushes a critical desktop notification when your power drops below a defined threshold while discharging.
The script relies on notify-send to push critical GUI warnings to your desktop environment.
Ubuntu
sudo apt-get install notify-osdDebian:
sudo apt-get install libnotify-binOther Distributions: Install it via your standard package manager, or visit vaskovsky.net for guidance.
- Download or clone the script to your machine.
- Make it executable:
chmod +x batAlert.sh- Move the script to a permanent location (e.g.,
~/scripts/batAlert.sh). - Open your crontab configuration:
crontab -e- Add the following line to run the script every minute (make sure to replace
/path/to/with your actual directory path):
* * * * * /path/to/batAlert.sh >> /tmp/battery.logBy default, the script will trigger an alert when your battery hits 10%. You can adjust this by opening batAlert.sh and editing the THRESHOLD variable on line 9:
THRESHOLD="10" # Change this to your preferred percentageFree to use. Open source. Lovely.