Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (2) </ 1 [2] >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Enabling the power button for shut down.< Next Oldest | Next Newest >
Juanito Offline





Group: Members
Posts: 1601
Joined: Sep. 2005
Posted: Dec. 11 2006,04:52 QUOTE

You need to install the acpid daemon - either by "apt-get install acpid" or by downloading the deb package and "dpkg -i /path-to-file/acpid_blah_blah.deb" or by downloading and installing the acpid .bz.tar from the acpid project site.

If you install acpid with apt-get, it also installs a couple of default files to handle power button events. Basically, when the acpi daemon sees an event, it looks in /etc/acpi/events/ for instructions on what to do for that event and then executes the command(s) referenced by the event file. The default files for a power button event are:

/etc/acpi/events/powerbtn
/etc/acpi/powerbtn.sh

The contents of these files are:

# /etc/acpi/events/powerbtn
# This is called when the user presses the power button and calls
# /etc/acpid/powerbtn.sh for further processing.

# Optionally you can specify the placeholder %e. It will pass
# through the whole kernel event message to the program you've
# specified.

# We need to react on "button power.*" and "button/power.*" because
# of kernel changes.

event=button[ /]power
action=/etc/acpi/powerbtn.sh

---------------------------

#!/bin/sh
# /etc/acpi/powerbtn.sh
# Initiates a shutdown when the power button has been
# pressed.

/sbin/init 0

By default, acpid creates a log file /var/log/acpid. This log file will allow you to see if your system is reacting to acpi events. Here is an example from my machine.

[Wed Nov 15 12:10:02 2006] starting up
[Wed Nov 15 12:10:02 2006] 1 rule loaded
..
[unplug ac adapter]
..
[Wed Nov 15 12:22:25 2006] received event "ac_adapter AC 00000080 00000000"
[Wed Nov 15 12:22:25 2006] completed event "ac_adapter AC 00000080 00000000"
[Wed Nov 15 12:22:25 2006] received event "battery BAT0 00000080 00000001"
[Wed Nov 15 12:22:25 2006] completed event "battery BAT0 00000080 00000001"
[Wed Nov 15 12:22:25 2006] received event "processor CPU0 00000080 00000007"
[Wed Nov 15 12:22:25 2006] completed event "processor CPU0 00000080 00000007"
..
[press power button briefly - note that the action in powerbtn.sh was commented out so there was no actual shutdown]
..
[Wed Nov 15 12:23:03 2006] received event "button/power PBTN 00000080 00000001"
[Wed Nov 15 12:23:03 2006] executing action "/etc/acpi/powerbtn.sh"
[Wed Nov 15 12:23:03 2006] BEGIN HANDLER MESSAGES
[Wed Nov 15 12:23:03 2006] END HANDLER MESSAGES
[Wed Nov 15 12:23:03 2006] action exited with status 0
[Wed Nov 15 12:23:03 2006] completed event "button/power PBTN 00000080 00000001"

In order to find out how DSL executes a shutdown by right-clicking on the desktop, you can look in /home/dsl/.fluxbox/menu:

  [submenu] (Power Down) {}
      [exec] (Shutdown){ exitcheck.sh shutdown}      
      [exec] (Reboot){ exitcheck.sh reboot}

So, if you modify /etc/acpi/powerbtn.sh to read as follows, save it and add both powerbtn files to .filetools.lst, you can execute a "graceful" shutdown by pressing the power button briefly (if you hold the button too long, the shutdown will not be so graceful..)

#!/bin/sh
# /etc/acpi/poweroff.sh
# Initiates a shutdown when the power putton has been
# pressed.

#/sbin/init 0
/usr/local/bin/exitcheck.sh shutdown
# or /usr/local/bin/exitcheck.sh reboot

I tried this and it works fine on my Dell Latitude D400
Back to top
Profile PM 
5 replies since Dec. 08 2006,03:37 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (2) </ 1 [2] >/
reply to topic new topic new poll
Quick Reply: Enabling the power button for shut down.

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code