Xfce Radeon power profile applet

If you are running Linux on a computer with older Radeon graphics card from HD 4000, HD 3000 or HD 2000 series GPUs, you have probably noticed issues with power profile setting. The open source “Radeon” driver handles power setting wrong and the usually recommended proprietary flgrx driver ceased to support older hardware. It is possible to use legacy radeon driver, but if you want to stick with the open source one, you should be able to manually adjust graphic card’s power settings.

There is a nice applet for KDE just ready for use. It seemed to be a bit unstable to me, but usually works. From a look at a user’s manual, it should be possible to recreate it for use in other desktop environments. How to do it in Xfce?

XFCE Radeon power profile applet

One possible way is to use Generic monitor applet for monitoring current power profile settings and a Launcher applet for changing it.

First, we must prepare configuration files. This is a bit crude way how to do it, but it works fine. You need to run these commands as a root/superuser. If the debug file system isn’t mounted yet (nothing in /sys/kernel/debug folder), mount it by:

mount -t debugfs none /sys/kernel/debug

This allows the applet to monitor graphic card clock frequencies and other data (see tooltip in image above).

Now, we must give the user access to configuration files. Detailed graphic card data is stored in /sys/kernel/debug/dri/0/radeon_pm_info and changing power profile is possible by modifying the value in /sys/class/drm/card0/device/power_profile.

chmod a+x /sys/kernel/debug
chmod a+x /sys/kernel/debug/dri
chmod a+x /sys/kernel/debug/dri/0
chmod a+r /sys/kernel/debug/dri/0/radeon_pm_info

chmod a+rw /sys/class/drm/card0/device/power_profile

Now, you should try if everything works by writing a valute into power_profile by using echo. Following values are supported: low/mid/high/auto/default. Meaning of those values are explained in X.org wiki. Be careful with the “low” setting, it could cause issues. If everything works, values in radeon_pm_info should be changing.

Displaying and manipulating the data is a matter of writing three simple scripts.

First two are basically one-liners for changing power profile. This could be probably done just by using the right command in Launcher applet, but I had some issues there and writing a script was a faster way to victory. Let’s call the first one “set_GPU_low”:

#!/bin/bash
echo low > /sys/class/drm/card0/device/power_profile
exit 0

and the second one “set_GPU_high” with analogical command inside:

#!/bin/bash
echo high > /sys/class/drm/card0/device/power_profile
exit 0

I am using just those two values, but you can of course try more.

The last script is a bit more complicated. It reads data from both configuration files and displays them in two ways. First, as a direct text output for Generic monitor applet and the second as it’s tooltip.

#!/bin/bash

export gpu_nastaveni=$(cat /sys/class/drm/card0/device/power_profile)
export gpu_detailni=$(cat /sys/kernel/debug/dri/0/radeon_pm_info)

if [ “$gpu_nastaveni” == “low” ]; then
echo “<txt><span weight=\”bold\” fgcolor=\”Green\”>LOW</span></txt><tool>$gpu_detailni</tool>”;

elif [ “$gpu_nastaveni” == “default” ]; then
echo “<txt><span weight=\”bold\” fgcolor=\”Red\”>Default</span></txt><tool>$gpu_detailni</tool>”;

elif [ “$gpu_nastaveni” == “high” ]; then
echo “<txt><span weight=\”bold\” fgcolor=\”Red\”>HIGH</span></txt><tool>G$gpu_detailni</tool>”;
else
echo “<txt><span weight=\”bold\” fgcolor=\”Red\”>ERROR</span></txt><tool>Error!</tool>”;
fi

Simple, right? Now, just make these scripts executable by using chmod +x and move them to /usr/bin folder.

From now on, it should be straightforward. Add Generic monitor applet to your panel and configure it like this:

applet-wiev

30s  refresh period isn’t too comfortable, but it is easy on computer’s resources.

And finally, set up the Launcher applet with configuration-changing scripts.

You can use some better icons for it, these are just some Xfce defaults, that happened to exist in my installation.

And BAM! that’s it. This method has been tested on Mint and Mint-Debian. Other distributions may use different folder system, so be creative!

Leave a Reply

Your email address will not be published. Required fields are marked *