The one thing that I really dislike about Linux is its battery life. It drains too fast on a Linux machine than it does on Windows or Mac.
There are some tools and practices that we can follow to improve the battery life on a Linux, and particularly on Ubuntu-
Use tlp
This tiny utility can help us to maximize battery life. Install it with this command:
sudo tlp start
Now it will automatically start with the system. It will detect the power source automatically and change the power profile accordingly to give the optimized battery life.
You can see a lot of battery and power-related information with this command:
sudo tlp-stat
Use -s for a short output-
sudo tlp-stat -s
Install Powertop
Install powertop with this command if it's not installed:
sudo apt install powertop
Now unplug the AC adapter and run the calibration to get more accurate information out of it-
sudo powertop --calibrate
Don't freak out if your screen goes all black. It will take a couple of minutes to calibrate so wait patiently without panicking. I know this because I did panic when it stayed there with a black screen for long.
Once the calibration is done, you can start the powertop and see some power status-
sudo powertop
Now do the autotune to adjust some of the settings to improve the power usage:
sudo powertop --auto-tune
Ubuntu Power Statistics
Launch the Power Statistics from your application menu in Ubuntu.
Now click on the Laptop battery in the opened window-
Here two stats are important to calculate your battery's original capacity - Energy when full and Energy (design)
Energy when full - Amount of power your battery can currently store with a full charge.
Energy (design) - Amount of power your battery could store originally with a full charge
Now divide Energy when full by Energy (design) and multiply the result by 100 and you will get the percentage of the current capacity of your battery.
43.9/48 * 100 = 91.45%
It means, my battery can currently hold 91.45% of its original capacity, which is good. If it's below 50% then you might want to replace your battery.