diff options
Diffstat (limited to 'tdecore/tdehw/tdehardwaredevices.cpp')
| -rw-r--r-- | tdecore/tdehw/tdehardwaredevices.cpp | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/tdecore/tdehw/tdehardwaredevices.cpp b/tdecore/tdehw/tdehardwaredevices.cpp index c636e0888..fb08ae486 100644 --- a/tdecore/tdehw/tdehardwaredevices.cpp +++ b/tdecore/tdehw/tdehardwaredevices.cpp @@ -3366,12 +3366,12 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist // Always assume that these two fully on/fully off states are available powerstates.append(TDESystemPowerState::Active); powerstates.append(TDESystemPowerState::PowerOff); - if (line.contains("standby")) { - powerstates.append(TDESystemPowerState::Standby); - } if (line.contains("freeze")) { powerstates.append(TDESystemPowerState::Freeze); } + if (line.contains("standby")) { + powerstates.append(TDESystemPowerState::Standby); + } if (line.contains("mem")) { powerstates.append(TDESystemPowerState::Mem); } @@ -3440,17 +3440,34 @@ void TDEHardwareDevices::updateExistingDeviceInformation(TDEGenericDevice* exist } ++valuesdirit; } - // Suspend-to-RAM requires a combination of 'mem' and 'deep' in two different files - if (powerstates.contains(TDESystemPowerState::Mem) && - suspendmodes.contains(TDESystemSuspendMode::SuspendToRAM)) { - powerstates.append(TDESystemPowerState::Suspend); - powerstates.remove(TDESystemPowerState::Mem); + // Freeze can also be set if /sys/power/mem_sleep exists and contains 's2idle' + if (!powerstates.contains(TDESystemPowerState::Freeze) && + powerstates.contains(TDESystemPowerState::Mem) && + suspendmodes.contains(TDESystemSuspendMode::Standby)) { + powerstates.append(TDESystemPowerState::Freeze); + } + // Standby can also be set if /sys/power/mem_sleep exists and contains 'shallow' + if (!powerstates.contains(TDESystemPowerState::Standby) && + powerstates.contains(TDESystemPowerState::Mem) && + suspendmodes.contains(TDESystemSuspendMode::Standby)) { + powerstates.append(TDESystemPowerState::Standby); + } + // Suspend-to-RAM can be set in various ways (not necessarily all available in the same system) + // 1) if /sys/power/mem_sleep exists and contains 'deep' + // 2) if /sys/power/mem_sleep does not exists, requires support for 'mem' in /sys/power/state + if (!powerstates.contains(TDESystemPowerState::Suspend) && + powerstates.contains(TDESystemPowerState::Mem)) { + if (suspendmodes.contains(TDESystemSuspendMode::SuspendToRAM) || suspendmodes.count() == 0) { + powerstates.append(TDESystemPowerState::Suspend); + } } + powerstates.remove(TDESystemPowerState::Mem); // Hibernation and Hybrid Suspend are not real power states, being just two different // ways of suspending to disk. Since they are very common and it is very convenient to // treat them as power states, we do so, as other power frameworks also do. if (powerstates.contains(TDESystemPowerState::Disk) && - hibernationmethods.contains(TDESystemHibernationMethod::Shutdown)) { + (hibernationmethods.contains(TDESystemHibernationMethod::Shutdown) || + hibernationmethods.contains(TDESystemHibernationMethod::Platform))) { powerstates.append(TDESystemPowerState::Hibernate); } if (powerstates.contains(TDESystemPowerState::Disk) && |
