How to manage power profiles over D-Bus with power-profiles-daemon on Linux

Power-profiles-daemons is a free and open source project designed to handle system power profiles over D-Bus. The two major Linux desktop environment, GNOME and KDE Plasma, are nicely integrated with it, allowing the user to easily manage power profiles from their dedicated power manager interfaces, but it is also possible to switch profiles and retrieve information about them from the command line, using a dedicated utility.

In this tutorial we learn how to install power-profiles-daemon, and how to use it to manage power profiles on Linux.

In this tutorial you will learn:

  • How to install power-profile-daemons on the major Linux distributions
  • How to switch power profile when using GNOME or KDE Plasma
  • How to manage power profiles from the command line
  • How to run a single command under a power profile
How to manager power profiles over dbus with power-profiles-daemon on linux
How to manager power profiles over D-Bus with power-profiles-daemon on Linux

Category Requirements, Conventions or Software Version Used
System Distribution independent
Software power-profiles-daemon
Other Administrative privileges are needed to install required packages
Conventions # – requires given linux-commands to be executed with root privileges either directly as a root user or by use of sudo command $ – requires given linux-commands to be executed as a regular non-privileged user

Installation

Power-profiles-daemon is free and open source software. Its source code is available on gitlab, and it is packaged in the official repositories of the most used Linux distributions. If you are using recent versions of GNOME or KDE Plasma, chances are the package is already installed. If for some reason, it is not the case, it can be easily installed. The installation command varies depending on the system we are using:

Distribution Installation command
Debian/Debian-based distributions
$ sudo apt install power-profiles-daemon
Fedora/Fedora-based distributions (RHEL, Rocky Linux, etc…)
$ sudo dnf install power-profiles-daemon
Archlinux
$ sudo pacman -S power-profiles-daemon



Twitter icon Follow LinuxConfig.org on Twitter for the latest tips and tricks about Linux!

The power-profiles-daemon package includes a systemd service unit. To start the service, and make sure it is automatically started on boot, we need to run the following command:

$ sudo systemctl enable --now power-profiles-daemon

If the service fails to start it may be due to incompatibilities with other running services such as tlp, which are also used to manage power settings. Make sure you stop and disable them if you want to use power-profiles-daemon.

The power profiles

The power-profiles-daemon utility makes use three power profiles:

  • power-saver
  • balanced
  • performance

The first two are always available, while the third is available only on specific systems. As we already said, if we are using GNOME or KDE Plasma, we can check the power profile currently in use, and eventually change it, right from the dedicated graphical interfaces.



In recent versions of GNOME, for example, we can do it right from the gnome-shell menu, without launching the full-fledged settings application:

Managing power profiles from the GNOME shell
Managing power profiles from the GNOME shell

Similarly, on Kde Plasma, we can switch power profiles right from the power manager widget:

Managing power profiles from the KDE Plasma "Battery and Brightness" applet
Managing power profiles from the KDE Plasma “Battery and Brightness” applet

Furthermore, by using the power-manager section of the Plasma desktop settings, we have the chance to associate a power profile with a specific system state (On AC Power, On battery, On Line Battery):

In KDE Plasma we can associate a power profile with a specific energy state
In KDE Plasma we can associate a power profile with a specific energy state

Switching power profile from the command line

At the moment of writing none of the less know Linux desktop environment, such as Xfce, is integrated with power-profiles-daemon. When working in such environments (or even in more minimal ones), however, we can still manage power profiles by using a command line utility: powerprofilesctl. The tool can be used to retrieve information about the available profiles and get or set the current one.

To get the power profile currently in use we just need to invoke “powerprofilesctl” and specify the “get” action. When invoked this way, the tool returns just the name of the profile:

$ powerprofilesctl get
balanced

To retrieve the list of all the available profiles and information about the driver used to implement them, instead, we can use the “list” action, or just invoke powerprofilesctl without any argument:

$ powerprofilesctl list 
performance:
    Driver:     intel_pstate
    Degraded:   no

* balanced:
    Driver:     intel_pstate

  power-saver:
    Driver:     intel_pstate



As you can see, all the power profiles are available on my machine. They are implemented by using the “intel_pstate” driver.

In order to change the power profile in use, we need to use the “set” action, and pass the name of the profile we want to use as argument. Supposing we want to switch to the “power-saver” profile, for example, we would run:

$ powerprofilesctl set power-saver

Notice that since the utility runs over of D-Bus and makes use of specific polkit authorizations, we don’t need to launch it with escalated privileges.

Launching a single command with a specific power profile

One very nice feature of powerprofilesctl, is the ability to launch a single command with a specific power profile. Imagine, for example, we are using the “balanced” profile, but we want to build some code from source, using all the available machine power. By using the “launch” action, we may switch to the “performance” profile just to perform such task. Supposing we need to use the “make” command in such fashion, we would run:

$ powerprofilesctl launch --profile performance make

Conclusions

In this tutorial we learned how to use power-profiles-daemon to manage power profiles over DBus. We saw how to install the power-profiles-daemon package on some of the most used Linux distributions, how it is nicely integrated both in GNOME and KDE Plasma, and how its possible to manage power profiles from the command line using the “powerprofilesctl” utility, which can also be used to run a single command under a specific power profiles. command.



Comments and Discussions
Linux Forum