As computers become more powerful and more efficient, they rapidly drain their batteries because they consume more electricity. While this might depend on the number of running applications, laptop moans are mainly caused by battery life especially when they are not plugged in throughout the day.
It is still possible however to get some improvements by some software tweaks and good practice. Notwithstanding the use of a lightweight desktop environment, laptop users running on Ubuntu have the possibility to extend the life of their batteries by using a power management utility called TLP.
In this article, we will provide a description of TLP and explain how to enable it on your Ubuntu laptop . We also provide some useful tips to help optimize power consumption. Finally we shall delve into Intel’s PowerTop utility which is a system diagnosis tool.
TLP is a free, feature-rich open source utility for battery use improvement on laptops running Linux distros such as Ubuntu.
Without having to delve deeper into technical details, the TLP tool can exploit Linux advanced power management to bring users its many benefits. Indeed, when your laptop is unplugged, i.e. running on its battery, the TLP operates by optimizing the hardware devices power usage. Here are some features of TLP :
- Many customization options and several power saving parameters
- Provides USB autosuspend with blacklist
- Uses dirty buffer timeouts and kernel laptop mode
- Power management for PCI Express active state (PCIe ASPM)
- Multi-core/hyper-threading process scheduler power awareness
- Supports processor “turbo boost” and “turbo core”
- PCI(e) bus devices runtime power management
- Wifi and audio power saving mode support
- Hard disk advanced power handling and spin down (non SSD) timeout (per disk)
- Radeon graphics power management support (KMS and DPM)
- SATA aggressive link power management (ALPM) support
- Includes an I/O scheduler (per disk)
The default settings that come with TLP are already optimized and perfectly tuned for better battery management so that you do not have to tweak anything. The configuration file can be found at /etc/default/tlp. This is said, TLP offers users different customization options in order to fulfill their specific needs. TLP is available in GUI and CLI (Command Line Interface or terminal) so that beginner and advanced users alike can use it as they see fit. All that is needed is to get TLP installed and that’s it !
Open up your terminal or command line either by pressing on Ctrl+Alt+T or through the Application Launcher.
You would first need to have an up-to-date repository index by running the command below :
sudo apt-get update
The package lists will be downloaded from the remote repositories and will be updated with information on the latest versions of packages along with their dependencies. Make sure to use sudo or a user with the required privileges.
In order to install TLP , invoke the command below:
sudo apt-get install tlp
You will be prompted with a Y/N question to continue the installation. Go ahead and enter Y in order to proceed with the installation. Depending on your Internet connection speed, this might take several seconds. Once completed, TLP will be added to the list of installed applications.
TLP will be running as a service after system start. You could check if it is up and running by using the command below :
sudo systemctl status tlp
Now that TLP is ready to be used, let’s start it in the terminal by running the following command :
sudo tlp start
In order to see the status of the TLP utility as well as detailed system information execute the command below:
sudo tlp-stat -s
As mentioned above, TLP operates initially using a default configuration that is perfectly tuned to fit the needs of your operating system and hardware. You can display the default configuration of TLP using the following command:
sudo tlp-stat -c
TLP allows you to view a detailed report about your current laptop battery. This can is achieved by using the -b switch as shown below :
sudo tlp-stat -b
To display the temperature of the CPU, issue the command below :
sudo tlp-stat -t
In order to remove TLP from your system, you could use the command below for instance :
sudo apt-get remove tlp
Besides CLI, TLP utility offers a graphical interface that can be installed from Linux Uprising PPA. This is because TLP is not available at the Official Ubuntu repositories as highlighted in the snapshot below.
You would first need to add the PPA which will be used to install the TLP graphical user interface application. Open your terminal ad issue the command below :
sudo add-apt-repository ppa:linuxuprising/apps
Allow few seconds for this to run.
As was done before in the case of CLI, you would need to run the command below beforehand in order to to have an up-to-date repository index:
sudo apt-get update
Now to install the TLP UI, run the command :
sudo apt-get install tlpui
You will be prompted with a Y/N question to continue the installation. Go ahead and enter Y in order to proceed with the installation. Depending on your Internet connection speed, this might take several seconds. Once completed, TLP UI will be added to the list of installed applications.
TPL UI is now ready to be used. You can launch it by searching for ‘tlp’ in the Application Launcher as follows:
This can also be done by running the command below in the Terminal :
This will launch the TLP UI application as shown in the snapshot below :
You could edit the TLP settings on the configuration tab above.
The statistics tab will enable you to view your battery and system statistics.
Using the checkbox TLP_ENABLE below :
You will have the possibility to enable or disable battery optimization feature through TLP, based on your settings.
To remove the TLP UI utility from your system , run the command below :
sudo apt-get remove tlpui
To also remove the added PPA, use the command below :
sudo rm /etc/apt/sources.list.d/linuxuprising-ubuntu-apps-bionic.list
You have seen two methods which allow you to install and use TLP. TLP utility will allow you to efficiently use your laptop battery on your Ubuntu system. You will hopefully start to notice some improvements on the way your battery is used after you run the TLP service. To know more about TLP, you can visit its website here.
In this section, you will find some short tips on how to ameliorate your average laptop battery lifespan and how to optimize its usage.
Since your laptop motherboard has to power all your USB connected devices such as webcams, USB keys, mouse , you would just need to eject them to save some juice unless this is absolutely necessary.
The webcam can be turned off using a function button. Your speakers should also be muted if you do not need sound, since every time your laptop beeps this can be a drain.
A Laptop screen can drain more power than some other devices of the laptop. This power-hungry screen can consume large amounts of your battery power in order for you to enjoy clear and bright looking display.
There is a nonlinear dependency between power consumed and brightness level. This means that increasing the brightness level in the lowest settings consumes less power than when stepping this up in the highest settings.
You can simply turn the brightness down and avoid the full level in order to save some power. Measurements on a typical laptop show that dropping to 2/3 brightness will save you about 1 Watt.
Wakeup events triggered by some applications can arouse an idle processor which leads to power consumption. There some applications which cause such wakeups, for instance flash in web pages, in which case you can choose to not install flash or simply close your browser tab when you don’t need it anymore. There are some tools that can help identify similar situations, like Intel’s PowerTop which is featured further down in this article.
Ubuntu offers a lightweight desktop environment called Lubuntu that does not require extensive computer power (graphics). To install Lubuntu, execute the command below :
sudo apt-get install lubuntu-desktop
Once finished, you could load Lubuntu desktop environment directly from the login screen.
Some common applications have lightweight alternatives. For example, you might want to use Gdebi (package installer) or AppGrid rather thenUbuntu Software Center or AbiWord instead of LibreOffice Writer .
The laptop built-in wireless networking capabilities are amongst the parts that sap the battery life the most. The battery is constantly being drained by Wi-Fi since power is continuously drawn by the wireless device, even when it is not connected since it is looking for available wireless networks nearby.
When there are no wireless networks available, you can simply turn off this device. On Ubuntu you can do this manually by switching to airplane mode as follows :
- Open up the Activities application and type in Wi-Fi
- Click on Wi-Fi tab to open the corresponding panel
- Switch on Airplane Mode. You wireless connection will be turned off until airplane mode is enabled again.
It is also possible turn off your Wi-Fi connection directly from the system menu:
- Simply click on the connection name and choose Turn Off
If you are at ease with the command line, you could issue the commands below to disable your WiFi :
- nmcli radio wifi off
To re-enable it, use the command :
- nmcli radio wifi on
For more on this, refer to the documentation as per the commands below :
- nmcli radio help
- nmcli radio wifi help
You might be using few applications on the frontend, but on the background, unknown to you, there could be many services running in the backend. These background processes are actually draining away your battery for instance, workspace, Compiz or dock .
The best remedy here is to stop unnecessary services from running at boot. We have written a detailed article on how to achieve this along with other methods which might help lower memory usage and thereby save some power.
In this section we will be looking at another Linux tool called PowerTOP that monitors your battery performance by setting appropriate system configuration to help manage power on your Linux laptop machine.
PowerTop is a diagnosis application created by Intel that helps users monitor power usage by active programs on a Linux laptop when it is unplugged. This terminal based utility offers an interactive mode allowing users to tweak several power management settings.
In order to install PowerTop on Ubuntu and similar distributions, run the command below:
sudo apt-get install powertop
In order to use this tool, the user would need to have root privileges or sudo rights since the information required by PowerTop, is retrieved from the system hardware directly.
To run PowerTop, issue the command below :
This will show the following interactive mode display :
Unplug your laptop so that the battery power usage can be monitored by PowerTop. In the snapshot above, one can see some statistics related to the overall power usage by the system and also by its power-hungry individual components that are using most of the system power or that are sending wake-up calls to the processor most frequently.
These are listed in the following categories: processes, devices, kernel works (kWork) , system timer and interrupts.
In order to navigate between the different tabs at the top, use Shift + Tab keys as mentioned on the bottom of the screen.
This shows information about the processor C-states which are used to reduce or optimize power consumption in idle mode .
This tab shows the frequency of wake-up calls to the CPU.
This tab displays similar data to the main but is only related to devices.
In tab you will find some useful power consumption optimization suggestions.
Minimizing system wake-ups would lead to maximizing battery power consumption. In the snapshot above :
“Bad” indicates that a given setting is not saving power, but it might be good system- performance wise.
“Good” shows that specific setting is saving power. Press [Enter] key to switch it to the other setting.
PowerTop allows you to generate a CSV report for several seconds. in the command below, we will generate a report for 5 seconds
sudo powertop –csv=output_report.txt –time=5s
In order to view the generated report, issue the command below in you preferred editor :
The output shows the following entries ;
Which indicates the top 10 power consumers.
Here we can see an overview of software power consumers, or the processes that consume the most power.
Device power report is provided above.
Process device activity is displayed.
Above we see the software settings which need tuning.
Here we can see some suggestions for optimal tuning.
In addition to the csv format, PowerTop allows also to generate a report html. This is achieved by using the command below :
This will generate a report that runs for a duration of 20 seconds.
The generated report can be displayed in a browser :
Now that you know PowerTop, you can install it and try to observe if there are improvements on the performance of your battery. If you want to use it for tuning other devices, you can visit this link for more details.
You have seen some tools as well as some tips that might help extend the life of your laptop battery. TLP utility will enable you to use your laptop battery on your Ubuntu system in an efficient way. PowerTop, a diagnosis tool, can help identify applications that are consuming high amounts of power and will allow you to tweak various power management settings. Good practice tips might also come in handy, like for instance dimming your laptop screen or unplugging connected USB devices .