Table of Contents
AntiX is a great distro. It's lightweight and easy to use. It comes with different flavor, and the Full flavor are jam-packed with many useful tools to do almost everything. However there is one important feature that is forgotten: the low battery notification
It's annoying that sometimes your laptop turn off immediately without warning in the middle of work. This simple script i provided will fix that annoyance. It uses python script and Zenity
to send notification popup that warns user when the battery hits certain threshold. Also there is an optional script that turn off your computer if the battery hit the 'critical' threshold.
- Python
- Bash
If you're on a new device, apt update
is mandatory, atleast once. apt upgrade
is recommended but not required.
sudo apt update
Then install these two important packages that will be used: git
and zenity
. git
will be used to clone the repo (download the scipt) to your local storage. And zenity
will be used to show a popup notification
sudo apt-get install git
sudo apt-get install zenity
- Clone the repository to your local storage
git clone https://github.com/etherealxx/batterantix
- Change directory into the script directory
cd batterantix
- Allow
execute
permission on every script there
chmod +x $PWD/*
- Edit the
~/.bashrc
file, so that the script can be ran everywhere. You can use any text editor you like, here i'll usegeany
geany ~/.bashrc
Add this line to the end of the text file, then save the text file
export PATH=$PATH:/home/$USER/batterantix
(assuming you didn't move the script's folder, and the git clone happened in /home/<yourusername>/
)
- Now edit the
startup
file so that the scipt will run everytime the laptop boots. (Note that you can use other text editor other thangeany
)
geany /home/ethereal/.desktop-session/startup
Add this line to the end of the text file, then save the text file
batterantix.py &
At this point the main script are ready to go, but the next step to 'automatically turn off the laptop when critical battery' are recommended.
- Edit the
rc.local
file so that the critical battery script will run as superuser everytime the laptop boots. (The shutdown command won't run without superuser. Note that you can use other text editor other thangeany
sudo geany /etc/rc.local
Add this line to the text file before the exit 0
line, then save the text file
batterantixcrit.py &
Finally, restart your laptop. If there's a popup few seconds after boot, the code works and installed successfully.
You can edit the line 6 and 7 of batterantix
to customize the low battery and critical battery threshold of your likings.
lowBatteryPercentage = 10
criticalBatteryPercentage = 4
Don't forget to also edit the line 6 of batterantixcrit
if you want to.
If you, for some reason, still want to continue your project even if the battery is low, and don't want to be annoyed by the notification constantly popping up, type this to your terminal
sudo killbatt.py
It will kill all Batterantix process, and you need to restart your laptop to make the script run normally again.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the GNU GPLv3 License. See LICENSE.md
for more information.
etherealxx - gwathon3@gmail.com
Project Link: https://github.com/etherealxx/batterantix