LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Laptop and Netbook
User Name
Password
Linux - Laptop and Netbook Having a problem installing or configuring Linux on your laptop? Need help running Linux on your netbook? This forum is for you. This forum is for any topics relating to Linux and either traditional laptops or netbooks (such as the Asus EEE PC, Everex CloudBook or MSI Wind).

Notices

Tags used in this thread
Popular LQ Tags ,

Reply
 
Thread Tools
Old 11-07-2006, 06:55 PM   #1
stardotstar
Member
 
Registered: Nov 2002
Location: /au/qld/bne/4157
Distribution: Gentoo mactel-linux
Posts: 221
Thanked: 0
What governs the power button behaviour?


[Log in to get rid of this advertisement]
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
stardotstar is offline  
Tag This Post ,
Reply With Quote
Old 11-07-2006, 08:30 PM   #2
hockeyman_102
Member
 
Registered: Apr 2006
Location: Washington
Distribution: Suse, CentOS
Posts: 101
Thanked: 0
check your bios. I've seen in in a few.
hockeyman_102 is offline     Reply With Quote
Old 11-09-2006, 09:32 PM   #3
dosnlinux
Member
 
Registered: Mar 2005
Distribution: slackware 11, arch 2007.08
Posts: 154
Thanked: 0
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.
dosnlinux is offline     Reply With Quote
Old 11-10-2006, 07:32 PM   #4
stardotstar
Member
 
Registered: Nov 2002
Location: /au/qld/bne/4157
Distribution: Gentoo mactel-linux
Posts: 221
Thanked: 0

Original Poster
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 is offline     Reply With Quote
Old 11-12-2006, 03:45 PM   #5
stardotstar
Member
 
Registered: Nov 2002
Location: /au/qld/bne/4157
Distribution: Gentoo mactel-linux
Posts: 221
Thanked: 0

Original Poster
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 ~ $
stardotstar is offline     Reply With Quote
Old 11-15-2006, 11:03 PM   #6
Tyante
LQ Newbie
 
Registered: Oct 2004
Location: California
Distribution: Slackware, Debian, FreeBSD
Posts: 10
Thanked: 0
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
Tyante is offline     Reply With Quote
Old 11-15-2006, 11:09 PM   #7
stardotstar
Member
 
Registered: Nov 2002
Location: /au/qld/bne/4157
Distribution: Gentoo mactel-linux
Posts: 221
Thanked: 0

Original Poster
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...
stardotstar is offline     Reply With Quote
Old 11-16-2006, 06:44 PM   #8
dosnlinux
Member
 
Registered: Mar 2005
Distribution: slackware 11, arch 2007.08
Posts: 154
Thanked: 0
You should be able to.
dosnlinux is offline     Reply With Quote
Old 11-18-2006, 03:28 AM   #9
Tyante
LQ Newbie
 
Registered: Oct 2004
Location: California
Distribution: Slackware, Debian, FreeBSD
Posts: 10
Thanked: 0
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.
Tyante is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Power-Off with Button? win32sux Linux - Hardware 6 07-01-2006 02:19 PM
Middle mouse button behaviour tomservo291 Linux - Software 0 02-17-2005 08:01 AM
Power Button for Shutdown gokul Linux - Hardware 4 01-24-2004 01:40 PM
Needs to push power button to power off? danpin Linux - Newbie 5 10-21-2003 09:08 PM
Filthy linmodem behaviour & panic button query Bert General 3 01-31-2002 07:00 AM


All times are GMT -5. The time now is 05:38 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration