1. Home
  2. Linux
  3. Create custom battery alerts linux laptop

How To Create Custom Battery Alerts For A Linux Laptop

The battery system for most desktop environments on Linux is pretty straightforward. It’ll send you a message when your laptop is charging, when the battery is about to die, and when the battery is done charging. For average users, this probably seems like it’s good enough. However, if you like to track your laptop’s battery life and track how much power you’re using, you’ll need something a little more robust. Introducing Battery Monitor: a Python 3 based application that allows users to create custom battery alerts. To use Battery Monitor, you need to be running Ubuntu, Debian or have the ability to compile the source code and run it.

Ubuntu

The developer behind the Battery Monitor tool is primarily targeting Ubuntu. Since Ubuntu is the primary OS for this software, users will have no trouble installing it. To get it working, first, add the PPA archive.

Note: Ubuntu 18.04 doesn’t appear to have support for Battery Monitory yet. Previous releases, however, work fine.

sudo add-apt-repository ppa:maateen/battery-monitor

Just adding the PPA to the system doesn’t mean that Battery Monitor is installed. First, you must refresh the Ubuntu software sources.

sudo apt update

Running the apt update tool usually will show software upgrades for Ubuntu. Please install these new software upgrades, as Battery Monitor may need them. Upgrades can easily be installed by running the apt upgrade command.

sudo apt upgrade -y

With the PPA working and everything up to date, Battery Monitor is ready for installation. To install, run this command:

sudo apt install battery-monitor

If you want to uninstall Battery Monitor, run:

sudo apt remove battery-monitor -y

Debian

Battery Monitor works on Debian, though the developer hasn’t explicitly said so. Specifically, the Ubuntu 16.04 Xenial package seems to work just fine. To install Battery Monitor, first, use wget to download the Debian package file.

Note: Battery monitor runs well on Debian Stable. Use at your own risk on Unstable and Testing.

wget https://launchpad.net/~maateen/+archive/ubuntu/battery-monitor/+files/battery-monitor_0.5.4-xenial_all.deb

Use the dpkg app to install Battery Monitor.

sudo dpkg -i battery-monitor_0.5.4-xenial_all.deb

Using the dpkg command to install an Ubuntu program on Debian is iffy. In this case, it is because the dependencies don’t automatically resolve. Luckily, it’s easy to solve this issue. To correct the dependency errors, run the apt install -f command.

sudo apt install -f

After apt install -f finishes fixing dependency issues; Battery Monitory should work just fine.

Install From Source

If you’re not an Ubuntu or Debian user but still want to use the Battery Monitor tool, you’ll have to resort to compiling everything from source. Start off by installing the Git package. This package will allow you to download and interact with code from Git-based sites.

Operating system not listed? Just search your package management tool for “Git” and install it!

Note: to run this software; you’ll need to install the correct dependency files.

Arch Linux

sudo pacman -S git

Fedora

sudo dnf install git

OpenSUSE

sudo zypper install git

Using Git, grab the latest Battery Monitor source code.

git clone https://github.com/maateen/battery-monitor.git

CD into the newly cloned source folder.

cd battery-monitor

In the source directory, run make to compile Battery Monitor.

sudo make install

When the compilation finishes, Battery Monitor should be ready to go!

Using Battery Monitor

When you install Battery Monitor, you’ll notice there are two options in the application menu. Specifically, you’ll see that there is a “Battery Monitor” and “Battery Monitor GUI” launch option. To start using the tool, launch “Battery Monitor.” This launch option opens up the monitor tool and runs it in the background.

Once Battery Monitor is running, start up the GUI tool to edit the settings.

Battery Monitor has several settings that the user can edit for their uses. By default, Battery Monitor only has two warning notifications set up. These warnings go off when the program determines your battery life is at 10% and 30%.

Want more frequent warnings? Look for “First custom warning at,” “Second custom warning at,” and “Third custom warning at.” Next to each of these text boxes, write out a number corresponding to battery percentage.

For example, if you’d like to have Battery Monitor let you know when your laptop is about halfway dead, write “50” in one of the custom notification slots.

To get the most out of Battery Monitor, we recommend following this setup for custom warnings.

First, change “low battery warning” from 30 to 20. Next, add 50 as one of the custom warning notifications (so that you’ll see a warning when your battery is 50% drained). After setting the 50% number, add  75 to another custom slot. This change will allow Battery Monitor to let you know when 25% is drained from your laptop.

Finally, change “very low battery” from 10 to 8. With these settings, you’re sure to get the most out of Battery Monitor. When you’re happy with the settings, click the “Save” button to apply the new changes instantly.

If you want custom battery alerts on Windows, check out this post that shows you how you can create them easily.

Comments are closed.