summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAceLan Kao <[email protected]>2017-05-05 21:04:00 +0800
committerAceLan Kao <[email protected]>2017-05-05 21:04:00 +0800
commit5c0d35ca6caf7bb0a0e9897a1a868e8406f3b112 (patch)
treefa4f957e228b6f4eba458aedcb1fdc00b75e0924
parent543e6c4235d7d64067d878d20175556161b87ee4 (diff)
skip the disabled backlight device
While adjusting the brightness, if there are more than one graphics card on the machine, then there might be more than one backlight interface directories under /sys/backlight. Only one of them is active, and in the code, KDE picks the first one in the list as the backlight device. It might pick the wrong one if the active device is the second one. So, we try skipping the disabled one and can fix the brightness issue on some machines with more than one graphics cards. Changes V2: 1. replace tab by 8 space 2. add file.close() after the file contain has been read Signed-off-by: AceLan Kao <[email protected]>
-rw-r--r--daemon/backends/upower/backlighthelper.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/daemon/backends/upower/backlighthelper.cpp b/daemon/backends/upower/backlighthelper.cpp
index fb5f7ed..e0eb6c4 100644
--- a/daemon/backends/upower/backlighthelper.cpp
+++ b/daemon/backends/upower/backlighthelper.cpp
@@ -76,6 +76,17 @@ void BacklightHelper::initUsingBacklightType()
QStringList firmware, platform, raw, leds;
Q_FOREACH(const QString & interface, interfaces) {
+ file.setFileName(BACKLIGHT_SYSFS_PATH + interface + "/device/enabled");
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ continue;
+ }
+
+ buffer = file.readLine().trimmed();
+ file.close();
+ if (buffer == "disabled") {
+ continue;
+ }
+
file.setFileName(BACKLIGHT_SYSFS_PATH + interface + "/type");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
continue;