You are not logged in.

#1 2012-08-08 12:37:32

nierro
Member
From: Milan, Italy
Registered: 2011-09-02
Posts: 849

[SOLVED] Upower 0.9.18 changes

Hi!
Today upower 0.9.18 has been released.
What's new? Simply, if you're using systemd, it will use systemd for suspend/hibernate.
Where is the problem? Well, all of my scripts in sleep.d pm directory won't work.
I can't understand very well this part of the wiki: https://wiki.archlinux.org/index.php/Sy … leep_hooks .
Is there anyone of you that already give

systemctl suspend

a try? And may be he already creates some sort of hooks for systemd? (in this case, can he put one script here, to make me understand the proper way to create them?)

Last but not least: i think upower deps must change : pm-utils should be an opt-dep and may be it should be told to the user, after upower's installation, that if he is using systemd. he should not install pm-utils too.
Hope you could follow and understand me.
Thanks!

Last edited by nierro (2012-08-08 14:13:19)

Offline

#2 2012-08-08 13:00:49

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: [SOLVED] Upower 0.9.18 changes

what exactly is unclear in the wiki (I wrote this part)? I know it could be a little bit more elaborate (maybe add an example).
It basically works the same, it's just that the scripts are put in another directory and get different parameters. Also the scripts are run in parallel (while pm-utils calls them one after another), but that shouldn't matter to most people.

a little OT: is pm-utils even still maintained? I never really liked it anyway since most of the provided hooks just seem to be crappy workarounds for things that should or already have been fixed in the kernel (video quirks, alsa ...). At least for me "systemctl suspend" or "echo mem > /sys/power/state" has always been working fine, so most of these hooks really seem to be obsolete by now (but feel free to correct me).

Offline

#3 2012-08-08 13:04:53

tomegun
Developer
From: France
Registered: 2010-05-28
Posts: 661

Re: [SOLVED] Upower 0.9.18 changes

You should be able to just tweak your hooks a bit to detect if you are in suspend/hibernate/resume/thaw correctly. Since I'm lazy, I didn't convert my hooks, but rather just created a compatibility hook:

#!/bin/bash

for hook in /etc/pm/sleep.d/*; do
        if [[ $1 == 'pre' ]] && [[ $2 == 'suspend' ]]; then
                echo "$hook suspend"
                $hook suspend
        elif [[ $1 == 'post' ]] && [[ $2 == 'suspend' ]]; then
                echo "$hook resume"
                $hook resume
        elif [[ $1 == 'pre' ]] && [[ $2 == 'hibernate' ]]; then
                echo "$hook hibernate"
                $hook hibernate
        elif [[ $1 == 'post' ]] && [[ $2 == 'hibernate' ]]; then
                echo "$hook thaw"
                $hook thaw
        else
                echo "invalid parameters"
        fi
done

Testing appreciated, probably still has some bugs.

Offline

#4 2012-08-08 13:27:48

nierro
Member
From: Milan, Italy
Registered: 2011-09-02
Posts: 849

Re: [SOLVED] Upower 0.9.18 changes

@65kid: so i should only copy all of my scripts in the new directory? And change resume/thaw with post and suspend/hibernate with pre? Is this right?
So what i was wondering is: with pm-utils (i don't like it too) i can make a script run during suspend but not during hibernate. In systemd there is no difference, or have i misunderstood?
Btw i think pm-utils will be maintained (probably it is important only for pm-powersave part of it, that can't be replaced by systemd for now).
@tomegun: i'd prefer to understand how systemd works with suspend and change my script rather than use your workaround. May be someone will find it useful though.

EDIT: obviously, thanks! wink
EDIT2: ok,  i see i have to pass two arguments to new systemd scripts: pre / post and hibernate/suspend. So 65kid do not read my previous question. smile
ANOTHER EDIT:

Therefore any custom hooks you may have created will not be run.

(archwiki) . Well, not only custom hooks, but every hooks, in (/usr/ib/pm-utils/sleep.d too) won't be executed, will it?

Last edited by nierro (2012-08-08 13:31:51)

Offline

#5 2012-08-08 13:34:54

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: [SOLVED] Upower 0.9.18 changes

nierro wrote:

@65kid: so i should only copy all of my scripts in the new directory? And change resume/thaw with post and suspend/hibernate with pre? Is this right?

this should work, yes.

nierro wrote:

So what i was wondering is: with pm-utils (i don't like it too) i can make a script run during suspend but not during hibernate. In systemd there is no difference, or have i misunderstood?

That's what the second parameter is for, it's either "suspend" or "hibernate" depending on what you invoked.
This imho makes more sense than the pm-utils parameters since in 99% of all cases you don't care whether you suspended or hibernated but mostly just want to know if you are going to sleep (pre) or waking up (post). But if you really want/have to differentiate between suspend/hibernate you just have to check the second parameter.

nierro wrote:

ANOTHER EDIT:

Therefore any custom hooks you may have created will not be run.

(archwiki) . Well, not only custom hooks, but every hooks, in (/usr/ib/pm-utils/sleep.d too) won't be executed, will it?

you're right, I'm going to fix this in the wiki.

Last edited by 65kid (2012-08-08 13:37:11)

Offline

#6 2012-08-08 13:45:25

nierro
Member
From: Milan, Italy
Registered: 2011-09-02
Posts: 849

Re: [SOLVED] Upower 0.9.18 changes

Thanks!
Ok, i succeeded changing my two scripts to be run in systemd.
But i encountered a problem there: when i run "systemctl suspend" it happened that: networkmanager stays on (and connection too) and when i resume, i am prompted with the exit menu of my xfce4 (the one that appears when you click the logount button) .
I remember the first problem (connection on) happened by echoing mem to /sys/power/state too...
EDIT: the strange thing is that i'm not using pm scripts to switch off my connection (for every /usr/lib/pm-utils/sleep.d/ hooks i touched a blank file in /etc/pm/sleep.d, so i'm only running my two scripts.) So why with pm-utils connectiong get lost, as it is expected to, while with systemd no?

Last edited by nierro (2012-08-08 13:47:01)

Offline

#7 2012-08-08 14:04:24

65kid
Member
From: Germany
Registered: 2011-01-26
Posts: 663

Re: [SOLVED] Upower 0.9.18 changes

nierro wrote:

Thanks!
Ok, i succeeded changing my two scripts to be run in systemd.
But i encountered a problem there: when i run "systemctl suspend" it happened that: networkmanager stays on (and connection too) and when i resume, i am prompted with the exit menu of my xfce4 (the one that appears when you click the logount button) .
I remember the first problem (connection on) happened by echoing mem to /sys/power/state too...
EDIT: the strange thing is that i'm not using pm scripts to switch off my connection (for every /usr/lib/pm-utils/sleep.d/ hooks i touched a blank file in /etc/pm/sleep.d, so i'm only running my two scripts.) So why with pm-utils connectiong get lost, as it is expected to, while with systemd no?

seems like networkmanager doesn't have a hook (pacman -Ql networkmanager | grep pm). My guess(!) is that it catches this via a dbus signal from upower, but since you use "systemctl suspend" it obviously doesn't get that (but that would mean that you should see the same behaviour if you use pm-suspend directly instead of the xfce menu!?). I also use networkmanager but this behaviour doesn't actually cause any problems for me. No idea about why the xfce4 menu pops up...

Offline

#8 2012-08-08 14:13:05

nierro
Member
From: Milan, Italy
Registered: 2011-09-02
Posts: 849

Re: [SOLVED] Upower 0.9.18 changes

Yes you're right! It seems that it is switched off by upower and a dbus call (tried with "pm-suspend" and the result is the same as "systemctl suspend" and "echo mem" ).
So, once upower 0.9.18 will hit our repo, this problem should be fixed.
The second problem only appears after a systemctl suspend (systemctl hibernate instead works perfectly, with tuxonice too, i would not have bet it...well it seems to work better than pm-utils with tuxonice instead big_smile )
Well, i tried again a systemctl suspend, and this time nothing pops up...don't know smile
I'm waiting for this update btw, and hope systemd will add better powersave support (as pm-powersave), so i will can get rid of pm-utils...
I mark this thread as solved, hope someone will find this useful.
Thank you very much for your time!

Offline

#9 2012-08-11 01:19:51

bwat47
Member
Registered: 2009-10-07
Posts: 638

Re: [SOLVED] Upower 0.9.18 changes

This really concerns me. I'm using systemd, and I currently need to use this fix for suspend/hibernate to work on my laptop (otherwide it doesn't supend at all, just blinking cursor, fan still running):  http://thecodecentral.com/2011/01/18/fi … orking-bug

Does this mean that this script will no longer work after the upower upgrade? Will I just need to move the script to the systemd directory? Would I need to edit the script (I would have no idea what to change)


EDIT:just tested the "systemctl suspend" command and it seems to work fine, so I take it that means I should be alright?

Last edited by bwat47 (2012-08-11 02:07:26)

Offline

Board footer

Powered by FluxBB