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.
- Display may be incorrect after switching forced performance level.
- Buttons won’t adjust their height, hence it’s ugly if you resize the widget to a taller one.
- 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.
/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.
We tend to use
echo to write into DPM files, so just go on, use
plasmoid.runCommand to execute echo.
Before use runCommand, one should add LaunchApp as a required extension in
plasmoid.runCommand(exec, [,argsList]) equals
exec args1 args2 args3 etc.