Bug 307228 - In Powerdevil's Advanced Settings, the shutdown on critical battery level doesn't work
Summary: In Powerdevil's Advanced Settings, the shutdown on critical battery level doe...
Status: RESOLVED FIXED
Alias: None
Product: solid
Classification: Frameworks and Libraries
Component: powermanagement-daemon (show other bugs)
Version: 4.9.1
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Dario Freddi
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-22 19:54 UTC by kero
Modified: 2015-02-25 23:28 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.11.2


Attachments
patch to help you really fix this problem (1.89 KB, patch)
2013-08-25 11:39 UTC, Alex Levkovich
Details

Note You need to log in before you can comment on or make changes to this bug.
Description kero 2012-09-22 19:54:33 UTC
As stated: in Powerdevil, under "Advanced Settings", i set it to shutdown completely the laptop, when the battery level becomes critical, but the shutdown does not work, nothing happens and the battery level still lowers.

Note 1: when I set it to suspend2ram or suspend2disk, it does works. It's only the shutdown which does not work.
Note 2: the same problem, even when I change the treshold for battery critical level (I tried 5%, 15, 20% ...).

Reproducible: Always

Steps to Reproduce:
1.Set the system to shutdown on critical battery, in advanced settings
2.Set the critical battery level (eg. 5%)
Actual Results:  
Does not shutdown.

Expected Results:  
Shutdowning.

Technical:
- netbook: Acer Aspire One 756 (Celeron 877, 4Go Ram, Intel Chipset)
- distro: Archlinux, uptodate (x86_64), with KDE 4.9.1
Comment 1 Alex Fiestas 2013-03-03 17:37:07 UTC
I can reproduce this in 4.10
Comment 2 Kai Uwe Broulik 2013-03-20 21:25:14 UTC
Problem lies in:
Powerdevilcore passes PowerDevilSettings::batteryCriticalAction() which is 3 for shutdown.
In the SuspendAction (which is eventually triggered after dozens of roundtrips), however, it checks for  "Mode" which has ShutdownMode = 8
3 != 8 and this is why shutdown doesn't work. ToRamMode is 1 and ToDiskMode is 2 which matches the number in powerdevilcore.
Comment 3 Oliver Henshaw 2013-04-02 16:07:52 UTC
Good find - looks like battery critical actions weren't ported in 0189a3a49142731db37db69b83fa5e49a85f84c9

Ideally we'd be using the SuspendSession::Mode enum everywhere rather than magic numbers.
Comment 4 Dario Freddi 2013-04-20 13:26:57 UTC
Git commit 05740a7b53ff1deebd5d83485c6ef901f2ce328d by Dario Freddi.
Committed on 20/04/2013 at 15:25.
Pushed by dafre into branch 'master'.

powerdevil: Do not use magic numbers for configuration.

People affected by 307228 might need to change their configuration.

M  +6    -4    powerdevil/kcmodule/global/GeneralPage.cpp

http://commits.kde.org/kde-workspace/05740a7b53ff1deebd5d83485c6ef901f2ce328d
Comment 5 Alex Levkovich 2013-08-22 09:40:05 UTC
This problem was not fixed for me in 4.11.0.
Comment 6 Kai Uwe Broulik 2013-08-22 09:49:26 UTC
Did you configure the action again? ie. change it to another, apply, and change it back and apply?
Comment 7 Alex Levkovich 2013-08-22 11:08:59 UTC
Yes
Comment 8 Alex Levkovich 2013-08-24 05:18:07 UTC
PowerDevil::BundledActions::SuspendSession::ShutdownMode

    enum Mode {
        None = 0,
        ToRamMode = 1,
        ToDiskMode = 2,
        SuspendHybridMode = 4,
        ShutdownMode = 8,
        LogoutDialogMode = 16,
        LockScreenMode = 32,
        TurnOffScreenMode = 64
    };

ShutdownMode == 8

powerdevil/daemon/powerdevilcore.cpp

bool Core::emitBatteryChargePercentNotification(int currentPercent, int previousPercent)
{
    if (m_backend->acAdapterState() == BackendInterface::Plugged) {
        return false;
    }

    if (currentPercent <= PowerDevilSettings::batteryCriticalLevel() &&
        previousPercent > PowerDevilSettings::batteryCriticalLevel()) {
        switch (PowerDevilSettings::batteryCriticalAction()) {
        case 3:
            emitRichNotification("criticalbattery", i18n("Battery Critical (%1% Remaining)", currentPercent),
                             i18n("Your battery level is critical, the computer will be halted in 30 seconds."));
            m_criticalBatteryTimer->start();
            break;
Comment 9 Alex Levkovich 2013-08-24 05:28:26 UTC
it should be case 8 or PowerDevil::BundledActions::SuspendSession::ShutdownMode. Am I right?
Comment 10 Christoph Feck 2013-08-25 11:08:30 UTC
Reopening based on comment #5. See also bug 323992.
Comment 11 Alex Levkovich 2013-08-25 11:39:31 UTC
Created attachment 81916 [details]
patch to help you really fix this problem

this patch for kde 4.11. It fixes the problem.
Comment 12 Weng Xuetian 2013-09-01 06:39:03 UTC
Hi, Alex, I committed your patch.. though I typed the wrong bug number commit message..

4.11.1 is already tagged yesterday so it will be included in 4.11.2 I guess.

http://commits.kde.org/kde-workspace/fdc4aa9c298004ccd397fd2b451065d52cbf1ee0
Comment 13 JimmySaville 2015-02-25 23:28:25 UTC
Sorry to dig up old thread but having issues with power management
machine will not shutdown or suspend on critical
critical at 60% have changed etc.
if below critical level at startup will boot so far then shutdown (during startup)
thats the only time critical shutdown/suspend works
killed battery in 3 months

Kubuntu 14.04
KDE 4.13.3
kernel 3.13.0-46

please let me know what logs etc I can provide
thanks in advance
alan