Radeon Dynamic Power Management Control Plasmoid

After nearly a week silent, I’m back with a new QML plasmoid for your KDE 4.x. Though I regarded it not as very helpful… :)

I think you probably know that AMD open-source Radeon driver has already supported dynamic power management (DPM) since kernel 3.11. Like the old lousy power-profile management, it’s controlled by things like echo high > /sys/class/drm/card0/device/power_dpm_force_performance_level. Not a big deal, but inconvenient if you got a laptop and need to control it frequently. Yeah, it won’t automatically switch to performance from battery when your laptop’s ac plugged, or vice versa.

Thus, here is the plasmoid applet I cooked today, it’s premature but capable. Although a few things I should mention here.

  1. Display may be incorrect after switching forced performance level.
  2. Buttons won’t adjust their height, hence it’s ugly if you resize the widget to a taller one.
  3. QML doesn’t support access to external files directly, so the method is dirty and you might not like it.

Well, if you want to know, I’ll talk about the implemention of write and read in QML.

Read

Thankfully, /sys/class/drm/card0/device/power_dpm_force_performance_level is a plain text file, at least it can be treated as one. So I use XMLHttpRequest to read this file. @_@ I told you that you won’t like it.

Write

We tend to use echo to write into DPM files, so just go on, use plasmoid.runCommand to execute echo.

I really appreciated aseigo in #plasma IRC chanel to help me figure this out. Just to blame KDE documentations for putting plasmoid API stuff under Javascript sector so I can’t find these in QML sector.

Before use runCommand, one should add LaunchApp as a required extension in metadata.desktop file.

X-Plasma-RequiredExtensions=LaunchApp

Basically, plasmoid.runCommand(exec, [,argsList]) equals exec args1 args2 args3 etc.

Comments