LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Laptop and Netbook (https://www.linuxquestions.org/questions/linux-laptop-and-netbook-25/)
-   -   What governs the power button behaviour? (https://www.linuxquestions.org/questions/linux-laptop-and-netbook-25/what-governs-the-power-button-behaviour-499553/)

stardotstar 11-07-2006 05:55 PM

What governs the power button behaviour?
 
Specifically I find that my power button kicks off a shutdown. From X or whatever the machine simply goes immediately into a shutdown.

I am running acpid and Gnome 2.16 which I have set the power manager configuration to "Ask Me" what to do when the power button is pressed.

I am not sure if it is a default rule in acpid or X that is taking effect because the Ask Me feature certainly is not.

Code:

stardotstar@spitfire /etc/acpi/events $ ls
a-ac-aticonfig  default        lm_battery  pmg_ac_adapter
a-lid-aticonfig  lm_ac_adapter  lm_lid      pmg_battery

so no event identified (default is not changed)

Code:

stardotstar@spitfire /etc/acpi $ cd actions/
stardotstar@spitfire /etc/acpi/actions $ ls
lm_ac_adapter.sh  lm_battery.sh  lm_lid.sh  pmg_switch_runlevel.sh

no power button action defined either...

Any pointers?

TIA

hockeyman_102 11-07-2006 07:30 PM

check your bios. I've seen in in a few.

dosnlinux 11-09-2006 08:32 PM

The stuff in /etc/acpi/acpi_handler.sh controls what the power button does.

The line in the file will look something like this:
Code:

case "$1" in
  button)
    case "$2" in
      power) if [ -f /var/run/s3 ]
                then rm -f /var/run/s3
                else /sbin/init 0
            fi
        ;;

Just change the stuff after "power)" to tell your computer what to do when the button is pressed.

stardotstar 11-10-2006 06:32 PM

Thank you for that I will check it later today...

As for the BIOS - this is a MacBook Pro so it is EFI and the issues around bios are complicated - the video drivers need a legacy bios emulation and that is provided but lots of progs that rely on legacy bios simply dont' work - memtest86 for instance.


Will

stardotstar 11-12-2006 02:45 PM

No script as such:

Code:

stardotstar@spitfire ~ $ sudo find / -iname "acpi_handler.sh"
find: /mnt/osx/Library/Documentation/Applications/GarageBand/GarageBand Getting Started.app/Contents/Resources/ko.lproj/GarageBand ������������.pdf: No such file or directory
find: /mnt/osx/Library/Documentation/Applications/iDVD/iDVD Getting Started.app/Contents/Resources/ko.lproj/iDVD ������������.pdf: No such file or directory
find: /mnt/osx/Library/Documentation/Applications/iMovie/iMovie Getting Started.app/Contents/Resources/ko.lproj/iMovie HD ������������.pdf: No such file or directory
stardotstar@spitfire ~ $


Tyante 11-15-2006 10:03 PM

Look inside your /etc/acpi/ directory. Check for any scripts or for a folder possibly called events. One mine, there is a /etc/acpi/events/default file that runs the script /etc/acpi/acpi_handler.sh

If there is an /etc/acpi/events folder look through the files and see if any contain the /sbin/init 0

stardotstar 11-15-2006 10:09 PM

Yep, there it is:

Code:

spitfire acpi # cat default.sh
#!/bin/sh
# /etc/acpi/default.sh
# Default acpi script that takes an entry for all actions

set $*

group=${1/\/*/}
action=${1/*\//}
device=$2
id=$3
value=$4

log_unhandled() {
        logger "ACPI event unhandled: $*"
}

case "$group" in
        button)
                case "$action" in
                        power)
                                /sbin/init 0
                                ;;

                        # if your laptop doesnt turn on/off the display via hardware
                        # switch and instead just generates an acpi event, you can force
                        # X to turn off the display via dpms.  note you will have to run
                        # 'xhost +local:0' so root can access the X DISPLAY.
                        lid)
                                xset dpms force off
                                ;;

                        *)      log_unhandled $* ;;
                esac
                ;;

        ac_adapter)
                case "$value" in
                        # Add code here to handle when the system is unplugged
                        # (maybe change cpu scaling to powersave mode)
                        #*0)
                        #      ;;

                        # Add code here to handle when the system is plugged in
                        # (maybe change cpu scaling to performance mode)
                        #*1)
                        #      ;;

                        *)      log_unhandled $* ;;
                esac
                ;;

        *)      log_unhandled $* ;;
esac

so I can disable that behaviour there? and then map it to some other action as well - like hibernate...

dosnlinux 11-16-2006 05:44 PM

You should be able to.

Tyante 11-18-2006 02:28 AM

Quote:

Originally Posted by stardotstar
so I can disable that behaviour there? and then map it to some other action as well - like hibernate...

You can just disable it by commenting it out or deleting the line. Just add whatever command or script you want to run. You can run multiple commands. Put them each on their own line. It will run everything up till it hits the ";;" line. You can also add sleep button commands if your laptop has a sleep button and it is recognized.


All times are GMT -5. The time now is 02:32 PM.