You are not logged in.

#1 2013-02-03 08:00:31

theta
Member
From: India
Registered: 2010-01-16
Posts: 174

Power Management Systemd & ACPI

Hi,
I am having a lot of trouble configuring my power management. I basically want my monitor to go off  when I close my lid and disable suspend completely.
Since the time I have switched over to systemd, this has become a nuisance.
Following are my configuration files:

/etc/acpi/handler.sh

#!/bin/sh
# Default acpi script that takes an entry for all actions

# NOTE: This is a 2.6-centric script.  If you use 2.4.x, you'll have to
#       modify it to not use /sys

#minspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq`
#maxspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`
#setspeed="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"
#
#set $*

case "$1" in
    button/power)
        #echo "PowerButton pressed!">/dev/tty5
        case "$2" in
            PBTN|PWRF)  logger "PowerButton pressed: $2" ; poweroff ;;
            *)          logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/suspend)
#	sudo pm-suspend
	;;
    button/sleep)
        case "$2" in
            SLPB)   echo -n mem >/sys/power/state ;;
            *)      logger "ACPI action undefined: $2" ;;
        esac
        ;;
    ac_adapter)
        case "$2" in
            AC|ACAD|ADP0)
                case "$4" in
                    00000000)
                        echo -n $minspeed >$setspeed
                        #/etc/laptop-mode/laptop-mode start
                    ;;
                    00000001)
                        echo -n $maxspeed >$setspeed
                        #/etc/laptop-mode/laptop-mode stop
                    ;;
                esac
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
    battery)
        case "$2" in
            BAT0)
                case "$4" in
                    00000000)   #echo "offline" >/dev/tty5
                    ;;
                    00000001)   #echo "online"  >/dev/tty5
                    ;;
                esac
                ;;
            CPU0)	
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/lid)
	case $(cat /proc/acpi/button/lid/LID/state | awk '{print $2}') in
		closed) xset dpms force off ;;
		open) xset dpms force on ;;
	esac
        #echo "LID switched!">/dev/tty5
        ;;
    *)
        #logger "ACPI group/action undefined: $1 / $2"
        ;;
esac

/etc/systemd/logind.conf:

[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#Controllers=
#ResetControllers=cpu
#InhibitDelayMaxSec=5
HandlePowerKey=ignore
HandleSuspendKey=ignore
HandleHibernateKey=ignore
HandleLidSwitch=ignore
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=no

The following is very puzzling as it is a dmesg output after uninstalling pm-utils and disabling systemd-logind service, and systemd-suspend service. My system still wants to go to sleep when the sleep button is pressed and the log show messages from "PM:*" , whatever that is. I initially thought this was a pm-util message, but this persists even after uninstalling pm-utils. Please shed some light on this.

[   59.777378] hid-generic 0003:0A5C:4502.0004: input,hidraw1: USB HID v1.11 Keyboard [Broadcom Corp] on usb-0000:00:1a.0-2.2/input0
[   59.843893] usb 3-2.3: new full-speed USB device number 9 using uhci_hcd
[   59.975457] input: Broadcom Corp as /devices/pci0000:00/0000:00:1a.0/usb3/3-2/3-2.3/3-2.3:1.0/input/input17
[   59.975706] hid-generic 0003:0A5C:4503.0005: input,hidraw2: USB HID v1.11 Mouse [Broadcom Corp] on usb-0000:00:1a.0-2.3/input0
[  243.521043] PM: Syncing filesystems ... done.
[  243.934712] PM: Preparing system for mem sleep
[  245.898047] Freezing user space processes ... (elapsed 0.01 seconds) done.
[  245.910239] Freezing remaining freezable tasks ... (elapsed 0.01 seconds) done.
[  245.923674] PM: Entering mem sleep
[  245.923700] Suspending console(s) (use no_console_suspend to debug)
[  245.927021] sd 2:0:0:0: [sda] Synchronizing SCSI cache
[  245.927282] sd 2:0:0:0: [sda] Stopping disk
[  245.965636] ACPI handle has no context!
[  246.390201] PM: suspend of devices complete after 465.500 msecs
[  246.391048] PM: late suspend of devices complete after 0.839 msecs
[  246.433291] ehci_hcd 0000:00:1d.7: wake-up capability enabled by ACPI
[  246.446362] uhci_hcd 0000:00:1d.2: wake-up capability enabled by ACPI
[  246.449432] uhci_hcd 0000:00:1d.1: wake-up capability enabled by ACPI
[  246.452498] uhci_hcd 0000:00:1d.0: wake-up capability enabled by ACPI
[  246.455804] ehci_hcd 0000:00:1a.7: wake-up capability enabled by ACPI
[  246.469627] uhci_hcd 0000:00:1a.1: wake-up capability enabled by ACPI
[  246.472608] uhci_hcd 0000:00:1a.0: wake-up capability enabled by ACPI

Offline

#2 2013-02-03 11:04:13

rebootl
Member
Registered: 2012-01-10
Posts: 431
Website

Re: Power Management Systemd & ACPI

IMHO I don't think it's a good idea to disable systemd-logind.service, it's there to manage your user logins (man systtemd-logind.service).

My system still wants to go to sleep when the sleep button is pressed [...]

If you look closely at your handler.sh this is what you define there. (echo -n mem >/sys/power/state is the kernel call to trigger this) https://wiki.archlinux.org/index.php/Suspend

Edit: Also see https://wiki.archlinux.org/index.php/Ac … figuration.
As described there acpi_listen is useful to find the correct calls.

Edit2: I'd try to figure out the right calls for your system using acpi_listen instead of using:

$(cat /proc/acpi/button/lid/LID/state | awk '{print $2}')

. Having a quick look at the logind.conf manpage I must say I don't really get what the ..IgnoreInhibited= options are for, but maybe setting LidSwitchIgnoreInhibited= to no might help cause it's the only one defaulting to yes.

Regards

Last edited by rebootl (2013-02-03 12:08:36)


Personal website: reboot.li
GitHub: github.com/rebootl

Offline

#3 2013-02-03 15:25:07

theta
Member
From: India
Registered: 2010-01-16
Posts: 174

Re: Power Management Systemd & ACPI

This is my new handler.sh:

#!/bin/sh
# Default acpi script that takes an entry for all actions

# NOTE: This is a 2.6-centric script.  If you use 2.4.x, you'll have to
#       modify it to not use /sys

#minspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq`
#maxspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`
#setspeed="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"
#
#set $*

case "$1" in
    button/power)
        #echo "PowerButton pressed!">/dev/tty5
        case "$2" in
            PBTN|PWRF)  logger "PowerButton pressed: $2" ; poweroff ;;
            *)          logger "ACPI action undefined: $2" ;;
        esac
        ;;
#    button/suspend)
##	sudo pm-suspend
#	;;
#    button/sleep)
#        case "$2" in
##            SLPB)   echo -n mem >/sys/power/state ;;
#            *)      logger "ACPI action undefined: $2" ;;
#        esac
#        ;;
    ac_adapter)
        case "$2" in
            AC|ACAD|ADP0)
                case "$4" in
                    00000000)
                        echo -n $minspeed >$setspeed
                        #/etc/laptop-mode/laptop-mode start
                    ;;
                    00000001)
                        echo -n $maxspeed >$setspeed
                        #/etc/laptop-mode/laptop-mode stop
                    ;;
                esac
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
    battery)
        case "$2" in
            BAT0)
                case "$4" in
                    00000000)   #echo "offline" >/dev/tty5
                    ;;
                    00000001)   #echo "online"  >/dev/tty5
                    ;;
                esac
                ;;
            CPU0)	
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/lid)
	case $(cat /proc/acpi/button/lid/LID/state | awk '{print $2}') in
		closed) xset dpms force off ;;
		open) xset dpms force on ;;
	esac
        #echo "LID switched!">/dev/tty5
        ;;
    *)
        logger "ACPI group/action undefined: $1 / $2"
        ;;
esac

Even with the relevant lines commented out and a system restart, my system still wants to suspend tongue
Its become a mystery now. According to me I don't have anything other thatn systemd and acpid which cause automatic standby, but somehow there's some 3rd party involved.

With regards to the lid switch, I will try to put what acpi_listen gives as the acpi call.
And I already tried toggling the LidSwitchIgnoreInhibited option. Not working.

PS: I just temporarily disabled and stopped the logind service to check what is causing this mysterious suspend.

Edit:
This is my acpid log(tail part):

Feb  3 21:02:40 localhost acpid: client connected from 492[0:0]
Feb  3 21:02:40 localhost acpid: 1 client rule loaded
Feb  3 21:02:55 localhost acpid: client 492[0:0] has disconnected
Feb  3 21:02:55 localhost acpid: client 492[0:0] has disconnected
Feb  3 21:02:59 localhost acpid: client connected from 492[0:0]
Feb  3 21:02:59 localhost acpid: 1 client rule loaded
Feb  3 21:03:01 localhost acpid: client connected from 492[0:0]
Feb  3 21:03:01 localhost acpid: 1 client rule loaded
Feb  3 21:03:18 localhost acpid: client 492[0:0] has disconnected
Feb  3 21:03:18 localhost acpid: client 492[0:0] has disconnected
Feb  3 21:03:19 localhost acpid: client connected from 492[0:0]
Feb  3 21:03:19 localhost acpid: 1 client rule loaded
Feb  3 21:03:20 localhost acpid: client connected from 492[0:0]
Feb  3 21:03:20 localhost acpid: 1 client rule loaded

I dunno if this behaviour is correct. It seems like it is just connecting and disconnecting. No events like lid close, suspend are being logged.

Last edited by theta (2013-02-03 15:35:41)

Offline

#4 2013-02-03 17:32:11

rebootl
Member
Registered: 2012-01-10
Posts: 431
Website

Re: Power Management Systemd & ACPI

AFAIK to get the events logged you've to add e.g. for the lid closed:

closed) xset dpms force off
logger 'Lid closed' ;;

Here everything get's into the journal, my /var/log/acpid.log is empty. However this might differ for you.

[root@amd64box Simple_CMS]# journalctl -b |grep acpid
Feb 03 13:42:11 amd64box acpid[337]: starting up with netlink and the input layer
Feb 03 13:42:12 amd64box acpid[337]: 1 rule loaded
Feb 03 13:42:12 amd64box acpid[337]: waiting for events: event logging is off
Feb 03 13:42:22 amd64box acpid[337]: client connected from 373[0:100]
Feb 03 13:42:22 amd64box acpid[337]: 1 client rule loaded
Feb 03 13:42:22 amd64box acpid[337]: client connected from 373[0:100]
Feb 03 13:42:22 amd64box acpid[337]: 1 client rule loaded

I suppose you don't have gnome or another DE that could override acpid?


Personal website: reboot.li
GitHub: github.com/rebootl

Offline

#5 2013-02-04 12:08:39

theta
Member
From: India
Registered: 2010-01-16
Posts: 174

Re: Power Management Systemd & ACPI

I have openbox installed with all cutom apps. I also have upower installed but to my knowledge it doesn't have automatic power management.

I tried putting log commands inside handler.sh. None of them are getting logged. I believe this is the culprit:

Feb 04 17:31:05 boolean-pc acpid[1620]: waiting for events: event logging is off

Some switch or option may be needed to make acpi log events.

Offline

#6 2013-02-04 17:16:28

rebootl
Member
Registered: 2012-01-10
Posts: 431
Website

Re: Power Management Systemd & ACPI

Hi

As you can see I have the same message in my log. However I get the events logged as defined in my handler.sh. Just checked, logger is part of the util-linux package, you might have to install it. I suppose you have the right ruleset according to https://wiki.archlinux.org/index.php/Ac … figuration. Maybe try to remove upower for testing? Pretty sure Openbox has no power management.

Regards


Personal website: reboot.li
GitHub: github.com/rebootl

Offline

#7 2013-02-06 15:26:15

theta
Member
From: India
Registered: 2010-01-16
Posts: 174

Re: Power Management Systemd & ACPI

Logger is installed and the ruleset is correct.
I tried removing upower, but the same thing occurs.
All this started after shifting to systemctl. ACPI was working smoothly before that. Somehow I can't find the link between the 2.
Regards,

Offline

#8 2013-02-06 21:30:27

rebootl
Member
Registered: 2012-01-10
Posts: 431
Website

Re: Power Management Systemd & ACPI

One thing I notice is that your logging is different to mine. They start with

[   59.777378]...

acpid get's logged to it's own logfile, etc..

Are you deliberately still using syslog with systemd ?
Are the events logged in the journal ?
(Output of:)

journalctl -b | grep acpid

Personal website: reboot.li
GitHub: github.com/rebootl

Offline

#9 2013-02-10 16:40:37

theta
Member
From: India
Registered: 2010-01-16
Posts: 174

Re: Power Management Systemd & ACPI

Finally I have solved some of the problems.
I uninstalled initscripts and syslog-ng. Now I can see the acpi events being logged.
My handler.sh is :

#!/bin/sh 
# Default acpi script that takes an entry for all actions 
# NOTE: This is a 2.6-centric script.  If you use 2.4.x, you'll have to
#       modify it to not use /sys

#minspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq`
#maxspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`
#setspeed="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"
#
#set $*

case "$1" in
    button/power)
        #echo "PowerButton pressed!">/dev/tty5
        case "$2" in
            PBTN|PWRF)  logger "PowerButton pressed: $2" ; sudo /sbin/poweroff ;;
            *)          logger "ACPI action undefined: $2" ;;
        esac
        ;;
#    button/suspend)
##      sudo pm-suspend
#       ;;
#    button/sleep)
#        case "$2" in
##            SLPB)   echo -n mem >/sys/power/state ;;
#            *)      logger "ACPI action undefined: $2" ;;
#        esac
#        ;;
    ac_adapter)
        case "$2" in
            AC|ACAD|ADP0)
                case "$4" in
                    00000000)
                        echo -n $minspeed >$setspeed
                        #/etc/laptop-mode/laptop-mode start
                    ;;
                    00000001)
                        echo -n $maxspeed >$setspeed
                        #/etc/laptop-mode/laptop-mode stop
                    ;;
                esac
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
    battery)
        case "$2" in
            BAT0)
                case "$4" in
                    00000000)   #echo "offline" >/dev/tty5
                    ;;
                    00000001)   #echo "online"  >/dev/tty5
                    ;;
                esac
                ;;
            CPU0)       
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
        #case $(cat /proc/acpi/button/lid/LID/state | awk '{print $2}') in
    button/lid)
        case "$2" in
            LID)
                case "$3" in
                close) sleep0.5; xset dpms force off ; logger "CLOSING" ;;
                open) xset dpms force on ;;
                esac
                ;;
        esac
        logger "LID switched! |$1|$2|$3"
        echo "LID switched! $3">/dev/tty5
        ;;
    *)
        logger "ACPI group/action undefined: |$1|$2|$3"
        ;;
esac

This is what gets logged when I close my lid:

Feb 10 22:07:14 boolean-pc logger[3601]: CLOSING
Feb 10 22:07:14 boolean-pc logger[3602]: LID switched! |button/lid|LID|close
Feb 10 22:07:14 boolean-pc logger[3605]: LID switched! |button/lid|LID|open
Feb 10 22:07:15 boolean-pc logger[3607]: ACPI group/action undefined: |processor|LNXCPU:00|00000080
Feb 10 22:07:15 boolean-pc logger[3609]: ACPI group/action undefined: |processor|LNXCPU:01|00000080

So now the logger is working and acpi is parsing it correctly, but somehow the monitor isn't powering off.
I wonder what else could be the problem now.

Offline

#10 2013-02-10 17:30:02

rebootl
Member
Registered: 2012-01-10
Posts: 431
Website

Re: Power Management Systemd & ACPI

Dunno if it's a copy and paste issue but there should certainly be a white space between sleep and 0.5.

close) sleep0.5; xset dpms force off ; logger "CLOSING" ;;

So it isn't going to suspend anymore ?
After all it already looks a lot better now wink

Regards

Edit: However, I saw that even with the above typo xset dpms force off should still be executed... Not sure...

Last edited by rebootl (2013-02-10 17:37:07)


Personal website: reboot.li
GitHub: github.com/rebootl

Offline

#11 2013-02-11 08:00:32

theta
Member
From: India
Registered: 2010-01-16
Posts: 174

Re: Power Management Systemd & ACPI

I think its a typo. I'll check when I go home today.
Anyway I don't think thats the problem since I tried without the sleep also.

Plus I forgot to mention about the suspend problem:
I have a Fn key on my Dell Laptop. I had found out using acpi_listen that
Fn + Esc => Sleep
Fn + F1 => Suspend
Both were earlier causing suspend.

Somewhere down the line, tyring to enable my lid to turn off the monitor I did something that has disabled suspend with Fn + Esc.
And I can now control Suspend from Fn + F1 from /etc/systemd/logind.conf

Offline

#12 2013-02-17 14:01:27

theta
Member
From: India
Registered: 2010-01-16
Posts: 174

Re: Power Management Systemd & ACPI

The "sleep0.5" wasn't a typo. I corrected it and tried other combinations also.
None of them seem to work.

Offline

#13 2013-02-17 15:26:47

rebootl
Member
Registered: 2012-01-10
Posts: 431
Website

Re: Power Management Systemd & ACPI

Is the sleep/xset command working when executed from command line ?
Maybe see: https://wiki.archlinux.org/index.php/Backlight and https://wiki.archlinux.org/index.php/Di … _Signaling
(output of cat

/var/log/Xorg.0.log|grep "DPMS"

?)


Personal website: reboot.li
GitHub: github.com/rebootl

Offline

#14 2013-02-24 08:24:23

theta
Member
From: India
Registered: 2010-01-16
Posts: 174

Re: Power Management Systemd & ACPI

Yeah, the command works perfectly from command line.
I will try to use some other command just to make sure.

The output you asked is:

[theta@boolean-pc ~]$ cat /var/log/Xorg.0.log|grep "DPMS"
[    16.147] Initializing built-in extension DPMS
[    20.788] (**) NVIDIA(0): DPMS enabled
[theta@boolean-pc ~]$ 

PS: Sorry for the late reply. Was out of town.

Offline

#15 2013-02-24 14:27:01

TheFlyingFrenchman
Member
Registered: 2013-02-23
Posts: 9

Re: Power Management Systemd & ACPI

Hi guys,
I ve been working on my power management these days so here some things I understood, if they are of any help.

rebootl wrote:

Having a quick look at the logind.conf manpage I must say I don't really get what the ..IgnoreInhibited= options are for, but maybe setting LidSwitchIgnoreInhibited= to no might help cause it's the only one defaulting to yes.

According to the wiki, these inhibiters only work if you are using Gnome or KDE. So if you don't use one of these DE, let the inhibiters line commented and set the Handle* to "ignore" the way theta did. This, of course, if you do not want systemd to manage these ACPI events.

theta wrote:

The following is very puzzling as it is a dmesg output after uninstalling pm-utils and disabling systemd-logind service, and systemd-suspend service. My system still wants to go to sleep when the sleep button is pressed and the log show messages from "PM:*" , whatever that is.

That's because you set the Handle* to ignore in your logind.conf. So as a consequence, systemd is not handling these acpi events and cannot be faulty here.

Offline

#16 2013-02-24 15:14:17

theta
Member
From: India
Registered: 2010-01-16
Posts: 174

Re: Power Management Systemd & ACPI

TheFlyingFrenchman wrote:

Hi guys,
I ve been working on my power management these days so here some things I understood, if they are of any help.

rebootl wrote:

Having a quick look at the logind.conf manpage I must say I don't really get what the ..IgnoreInhibited= options are for, but maybe setting LidSwitchIgnoreInhibited= to no might help cause it's the only one defaulting to yes.

According to the wiki, these inhibiters only work if you are using Gnome or KDE. So if you don't use one of these DE, let the inhibiters line commented and set the Handle* to "ignore" the way theta did. This, of course, if you do not want systemd to manage these ACPI events.

theta wrote:

The following is very puzzling as it is a dmesg output after uninstalling pm-utils and disabling systemd-logind service, and systemd-suspend service. My system still wants to go to sleep when the sleep button is pressed and the log show messages from "PM:*" , whatever that is.

That's because you set the Handle* to ignore in your logind.conf. So as a consequence, systemd is not handling these acpi events and cannot be faulty here.

Thanks for reading this long post and trying to help out. This does clarify certain points of this discussion.
But unfortunately this still doesn't help me to get my monitor to go off with the lid being closed.
I would be grateful for any insights on that. As of now I have almost given up on it.

Edit1: And btw welcome to ArchLinux !

Last edited by theta (2013-02-24 15:16:55)

Offline

#17 2013-02-24 19:57:24

rebootl
Member
Registered: 2012-01-10
Posts: 431
Website

Re: Power Management Systemd & ACPI

I find it great that you didn't gave up on it yet. Unfortunately atm I'm a bit out of ideas too...


Personal website: reboot.li
GitHub: github.com/rebootl

Offline

#18 2013-02-25 08:34:58

TheFlyingFrenchman
Member
Registered: 2013-02-23
Posts: 9

Re: Power Management Systemd & ACPI

theta wrote:

And btw welcome to ArchLinux !

Thank's, and I am already loving it!

I will try to finish up my acpi configuration this week, if I can get it working the way I want it to, I will keep you informed.
Stand fast!

Offline

Board footer

Powered by FluxBB