See bug 399727 for a good description of what this code is for.
The new ui will show a new option like the following image
FEATURE: 399727
See bug 399727 for a good description of what this code is for.
The new ui will show a new option like the following image
FEATURE: 399727
No Linters Available |
No Unit Test Coverage |
Buildable 12466 | |
Build 12484: arc lint + arc unit |
daemon/actions/bundled/suspendsessionconfig.cpp | ||
---|---|---|
82 |
|
Oh and I'm sorry that this patch has sat idle for so long. Once you make my requested change, I'll see if I can help push this along. Thanks for your patience!
@ngraham I updated the patch with the comments, I'm not sure if I'm updating it corrrectly, I have tested it on my machine and it can suspend, but for some reason the dedicated keys to change the brightness are not working on my laptop. I'm still checking if this is related on how I build and test locally powerdevil or is related with my changes.
No, I can't use my keyboard to change brightness, but it might be related on how I test my changes. I need guidance on how can I test powerdevil changes locally.
It's a plasma component, so this might be helpful: https://community.kde.org/Guidelines_and_HOWTOs/Build_from_source/Test_plasma
I applied this patch to v5.15.4 tag and tested with that and it works (my machine is running plasma 5.15.4), I can change the brightness with the keyboard and set the suspend-then-hibernate option.
Very nice.
The position of the checkbox in the settings seems odd to me.
It would be great to align it below the "After" field.
Or perhaps the screenshot just does not justice to the UI.
This is how the module looks with the new option:
This thing's UI really needs to be rewritten in QML. Once we do that and give it a proper FormLayout style, the string can be shorter, but for now, seeing it in context, I feel like the string should be "Hibernate after 3 hours of sleep".
Also I wouldn't mind making the period configurable. If you don't want to do that in this patch though, that's fine.
The period configuration can only be done by adding a .conf file to any of these locations with the parameter HibernateDelaySec, current dbus API doesn't have anything to pass or modify this value, so user intervention is required to change the default timeout of 3 hours.
/etc/systemd/sleep.conf /etc/systemd/sleep.conf.d/*.conf /run/systemd/sleep.conf.d/*.conf /usr/lib/systemd/sleep.conf.d/*.conf
@ngraham there is currently a limitation with my current patch, as a user you will always have to enable the suspend after a period of time (Suspend Session > After) to enable the Suspend-then-hibernate option. I think this is not a good default, I can also move this option to a new group similar to "Buttons event handling", which also modifies the suspend behaviour.
Maybe something like this?
[ ] Automatically sleep [after 30 minutes | v] [ ] While asleep, hibernate after 3 hours ``
UI looks good enough for now. But is this the full diff? It seems like something got lost. The whole patch should include the changes from all commits in your branch, not just the last one.
Added new Suspend then Hibernate option
Summary:
See bug 399727 for a good description of what this code is for.
The new ui will show a new option like the following image
Reviewers: broulik, ngraham
Subscribers: soriano, abalaji, graesslin, ngraham, plasma-devel
Tags: Plasma
Differential Revision: https://phabricator.kde.org/D16425
Hi,
This patch doesn't seem to work for me. I have Arch Linux, powerdevil-5.15.5-1 and your patch applied. After clicking the check-box the "Apply" button doesn't get active. Therefore, this setting is not being saved.
Also, why does the checkbox label say "While asleep, hibernate after 3 hours"? This value can be overriden in /etc/systemd/sleep.conf
This patch doesn't seem to work for me. I have Arch Linux, powerdevil-5.15.5-1 and your patch applied. After clicking the check-box the "Apply" button doesn't get active. Therefore, this setting is not being saved.
Did you enable the Suspend Session option too? you need to enable the Suspend Session before using the new checkbox, it is the same behavior of "Even when an external monitor is connected" checkbox. Is a limitation on how powerdevil UI is built.
Also, why does the checkbox label say "While asleep, hibernate after 3 hours"? This value can be overriden in /etc/systemd/sleep.conf
It is the default timeout, there's no easy way to change it using a UI or a parameter, unless we want to point the users to modify a root-owned file.
Added new Suspend then Hibernate option
Summary:
See bug 399727 for a good description of what this code is for.
The new ui will show a new option like the following image
Reviewers: broulik, ngraham
Subscribers: soriano, abalaji, graesslin, ngraham, plasma-devel
Tags: Plasma
Differential Revision: https://phabricator.kde.org/D16425
Thanks. Let's wait for @broulik's review once he gets back from vacation (a few days, I think).
daemon/actions/bundled/suspendsession.cpp | ||
---|---|---|
137–138 | How about avoiding the duplicate suspendJob = backend()->suspend() calls by doing: suspendJob = backend()->suspend(m_suspendThenHibernateEnabled ? PowerDevil::BackendInterface::SuspendThenHibernate : PowerDevil::BackendInterface::ToRam); | |
173–174 | Factor the config.isValid() out of the two if statements | |
daemon/actions/bundled/suspendsessionconfig.cpp | ||
58 | Again configGroup().writeEntry<bool>("suspendThenHibernate", m_suspendThenHibernateEnabled != nullptr && m_suspendThenHibernateEnabled->isChecked()); | |
102 | Stray line swap | |
127 | Not sure if this is necessary, just delete m_suspendThenHibernateEnabled might be enough. |
Added new Suspend then Hibernate option
Summary:
See bug 399727 for a good description of what this code is for.
The new ui will show a new option like the following image
FEATURE: 399727
Reviewers: broulik, ngraham
Subscribers: soriano, abalaji, graesslin, ngraham, plasma-devel
Tags: Plasma
Differential Revision: https://phabricator.kde.org/D16425
daemon/actions/bundled/suspendsessionconfig.cpp | ||
---|---|---|
102 | Oh i see, that actually makes sense | |
127 | Yeah it crashes because you're probably not doing a null check somewhere. I would suggest initializing m_suspendThenHibernateEnabled to nullptr in the ctor, moving line 79 into this if block right above, and getting rid of this else block altogether, that way you don't wastefully allocate the object. After this, check for nullptr in every place you use m_suspendThenHibernateEnabled. | |
132 | After doing the above, this if block can be merged with the above if block, if you know what I mean. |
Added new Suspend then Hibernate option
Summary:
See bug 399727 for a good description of what this code is for.
The new ui will show a new option like the following image
Reviewers: broulik, ngraham
Subscribers: soriano, abalaji, graesslin, ngraham, plasma-devel
Tags: Plasma
Differential Revision: https://phabricator.kde.org/D16425
Sorry for the constant spam of the original commit message, I cannot make arcanist to pick up a new commit for this differential without deleting the old one.
Added changes based on code review comments
daemon/actions/bundled/suspendsessionconfig.cpp | ||
---|---|---|
45 ↗ | (On Diff #59170) | Move this to the initializer |
daemon/actions/bundled/suspendsessionconfig.cpp | ||
---|---|---|
45 ↗ | (On Diff #59170) | something like this? : ActionConfig(parent), m_suspendThenHibernateEnabled(nullptr) |
daemon/actions/bundled/suspendsessionconfig.cpp | ||
---|---|---|
45 ↗ | (On Diff #59170) | Yeah exactly. So a subtle detail of C++ constructors is any data members which are not primitive (like structs class instances) get implicitly initialized using their default constructor if they don't have an entry in the initializer list. So if you do everything in the constructor body you risk double initializing stuff, which is unnecessary overhead. Of course this is not the case with primitives like pointers which are just integers behind the scenes, so what you have is okay, but just for the sake of consistency, better to make use of the initializer list |
Summary:
See bug 399727 for a good description of what this code is for.
The new ui will show a new option like the following image
Reviewers: broulik, ngraham
Subscribers: soriano, abalaji, graesslin, ngraham, plasma-devel
Tags: Plasma
Differential Revision: https://phabricator.kde.org/D16425
I apologize if this is the wrong place to add this comment but I have a laptop where this applies and would benefit me. I am happy to help test this if you find it helpful. Thanks.
Feel free to download this patch (download raw diff) and apply it to powerdevil repo. You need to build the package and replace the one in your system.
If you use arch or a derivative I can help you with that.
I tried using it but my system does not suspend-then-hibernate mode.
You can check if your system supports it once you have systemd >= 239 and the following command returns true :
qdbus org.freedesktop.PowerManagement /org/freedesktop/PowerManagement CanSuspendThenHibernate
Or this one should have the same result :
qdbus org.freedesktop.PowerManagement /org/freedesktop/PowerManagement CanHibernate
I'd quite like to get this in as I'll end up moving part of this - and we've got too much bikeshedding here.
i18n("While asleep, hibernate after 3 hours")
If you don't know the timeout, don't write it. It's better to be vague than lie.
"Suspend, then hibernate after a period of inactivitiy"
FTR on ubuntu, and by extension kubuntu and also neon, hibernation is disabled by default to enable it you need to kick the disabling rule out of /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla.
The feature works very well!
Summary:
See bug 399727 for a good description of what this code is for.
The new ui will show a new option like the following image
Reviewers: broulik, ngraham
Subscribers: soriano, abalaji, graesslin, ngraham, plasma-devel
Tags: Plasma
Differential Revision: https://phabricator.kde.org/D16425
Btw, I think you could have used
arc amend
to update your commit message based on the differential description.
I'd be happy to land your change.
Great contribution !