mate-desktop / mate-power-manager

Power management tool for the MATE desktop
https://mate-desktop.org
GNU General Public License v2.0
59 stars 52 forks source link

Replace deprecated UPower functions with ConsoleKit2 equivalents #209

Closed joakim-tjernlund closed 7 years ago

joakim-tjernlund commented 7 years ago

Forward port of Infrit's CK2 path. This requires ConsoleKit2 0.9.2.

willysr commented 7 years ago

Tested on 2 different Slackware machines: desktop: hibernate OK laptop: hibernate + suspend not working

joakim-tjernlund commented 7 years ago

Did you also try the same changes for mate-session-manager? I don't know but perhaps mate-pwor-manager and mate-sesion-manager needs to be updated simultaneously.

willysr commented 7 years ago

I think i forgot to patch mate-power-manager and applied the one in mate-session-manager only.

i will try to test again tomorrow

willysr commented 7 years ago

OK, i re-tested in my desktop and it seems i wrote a wrong result in my previous comment desktop: suspend works, but not hibernate (it just went blank, but it restores back to desktop soon)

i will try to test on my laptop tomorrow

joakim-tjernlund commented 7 years ago

Maybe you need upower-0.99 as well?

willysr commented 7 years ago

Slackware 14.2 still uses the old 0.9.23

ryanpcmcquen commented 7 years ago

Suspend is working for me on FreeSlack 14.2. I am not sure what hibernate is supposed to do, but it does make the screen go blank.

joakim-tjernlund commented 7 years ago

@ryanpcmcquen As I recall, hibernate will dump RAM/state to SWAP and if swap is too small you get into trouble. We don't use hibernate though. Did hibernate work before trying this?

ryanpcmcquen commented 7 years ago

Ah, well I have no swap partition, so maybe that's why it doesn't do much here.

joakim-tjernlund commented 7 years ago

Did you also try the same changes for mate-session-manager? I don't know but perhaps mate-pwor-manager and mate-sesion-manager needs to be updated simultaneously.

ryanpcmcquen commented 7 years ago

I will recompile with those.

joakim-tjernlund commented 7 years ago

Any news?

ryanpcmcquen commented 7 years ago

Ha, forgot to retest, I believe everything is working but I will verify that tonight.

joakim-tjernlund commented 7 years ago

very long nights ...

ryanpcmcquen commented 7 years ago

OK, all is working! Sorry that took so long.

monsta commented 7 years ago

Interesting. In src/gpm-control.c, you've got a mixed logic... You ask consolekit to suspend/hibernate, but checking if it's allowed to do is still done via UpClient instance. :slightly_smiling_face:

    if (!LOGIND_RUNNING()) {
        g_object_get (control->priv->client,
                  "can-suspend", &allowed,
                  NULL);
        if (!allowed) {
            egg_debug ("cannot suspend as not allowed from policy");
            g_set_error_literal (error, GPM_CONTROL_ERROR, GPM_CONTROL_ERROR_GENERAL, "Cannot suspend");
            goto out;
        }
    }
    if (!LOGIND_RUNNING()) {
        g_object_get (control->priv->client,
                  "can-hibernate", &allowed,
                  NULL);
        if (!allowed) {
            egg_debug ("cannot hibernate as not allowed from policy");
            g_set_error_literal (error, GPM_CONTROL_ERROR, GPM_CONTROL_ERROR_GENERAL, "Cannot hibernate");
            goto out;
        }
    }
monsta commented 7 years ago

So it shouldn't work because properties were removed long ago (in this commit). Please rebase your branch for this PR on git master (https://github.com/mate-desktop/mate-power-manager/commit/a8bd6ca038e373cdb8a9b11409391c0fa85bc319) and test it with upower 0.99 again.

monsta commented 7 years ago

Just in case, a note to people who tested this PR: testing suspend/hibernate buttons in session shutdown dialog is not enough. :slightly_smiling_face:

monsta commented 7 years ago

Let's move to https://github.com/mate-desktop/mate-power-manager/pull/212 for some corrections to this PR.