Commit e1ed3648 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

On wakeup from suspend restore remembered keyboard brightness

Some laptops turn off keyboard backlighton their own when the lid is closed,
so when you close the lid, it will suspend and remember the turned off keyboard
backlight, and turn it back off on wake up.

This patch instead remembers the last keyboard brightness when it changes
and restores that value on wake up


(cherry picked from commit ede6bb92)
parent 53b8621e
......@@ -75,7 +75,9 @@ KeyboardBrightnessControl::KeyboardBrightnessControl(QObject* parent)
// My laptop sets the keyboard brightness to zero when I close the lid and it suspends
// this makes sure the keyboard brightness is restored when we wake up :)
connect(backend(), &PowerDevil::BackendInterface::resumeFromSuspend, this, [this] {
setKeyboardBrightnessSilent(keyboardBrightness());
if (m_lastKeyboardBrightness > -1) {
setKeyboardBrightnessSilent(m_lastKeyboardBrightness);
}
});
}
......@@ -158,6 +160,7 @@ bool KeyboardBrightnessControl::loadAction(const KConfigGroup& config)
void KeyboardBrightnessControl::onBrightnessChangedFromBackend(const BrightnessLogic::BrightnessInfo &info, BackendInterface::BrightnessControlType type)
{
if (type == BackendInterface::Keyboard) {
m_lastKeyboardBrightness = info.value;
Q_EMIT keyboardBrightnessChanged(info.value);
Q_EMIT keyboardBrightnessMaxChanged(info.valueMax);
}
......
......@@ -71,6 +71,7 @@ private:
int keyboardBrightnessPercent() const;
int m_defaultValue = -1;
int m_lastKeyboardBrightness = -1;
QString m_lastProfile;
QString m_currentProfile;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment