Free Web Hosting Provider - Web Hosting - E-commerce - High Speed Internet - Free Web Page
Search the Web

Updated: 6/16/03

acpid mini-howto

Assuming that your kernel booted and all is working well you will want to install and use acpid. First you need to check to see if /proc/acpi/event exists. If it exists then your good to go as far as kernel support.

Download acpid sourceforge.net (1.0.2 as of this writing)

tar zvxf acpid-1.0.x.tar.gz then make and make install

As root go ahead and execute acpid (note* in the future you will want to set this up to start during boot time, in slackware this would be done by creating an /etc/rc.d/rc.acpid script)

The Default setup for acpid puts two configurtion scripts in /etc:
/etc/acpi/acpi_handler.sh
/etc/acpi/events/default

You will need to make sure both these scripts are executable.

Here is where you can now start to see how this all works. Open up a shell and as root issue the command tail -f /var/log/messages. If you now hit the power button you should see something like this come up in your console(note* is will most likely be a little different on your computer):
logger: ACPI group button/power / action PWRF is not defined
This simply means that both ACPI and acpid are working, all that is left is to fix the configuration files. The first file is default, shown below...

bash-2.05b# cat /etc/acpi/events/default
# This is the ACPID default configuration, it takes all
# events and passes them to /etc/acpi/default.sh for further
# processing.

# event keeps a regular expression matching the event. To get
# power events only, just use something like "event=button power.*"
# to catch it.
# action keeps the command to be executed after an event occurs
# In case of the power event above, your entry may look this way:
#event=button power.*
#action=/sbin/init 0

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

event=.*
action=/etc/acpi/acpi_handler.sh %e
bash-2.05b#

The file as you can see is pretty strait forward and well commented. In its current state it simply takes events from acpid and passes them to acpi_handler.sh. I personally see no reason to change it but instead change acpi_handler.sh to do my bidding when it recieves events from the default file. Lets have a look at the default acpi_handler.sh shall we?

bash-2.05b# cat /etc/acpi/acpi_handler.sh
# a sample skeleton for handling ACPI events

if [ $# != 1 ]; then
exit 1
fi
set $*

case "$1" in
           button)
                     case "$2" in
                               power) /sbin/init 0
                                         ;;
                               *) logger "ACPI action $2 is not defined"
                                         ;;
                     esac
                     ;;

           *)
                     logger "ACPI group $1 is not defined"
                     ;;
esac
bash-2.05b#

Well this is fine and all but on my computer which is an hp pavilion the power button is called PWRF not power and its located in /proc/acpi/button/power not /proc/acpi/button/. Your computer will most definitly have something different as well and you can of course find out with the tail command mentioned earlier. I will now give an example of how I would go about fixing mine, which should make it easy for even those not real savy with sh to apply the changes to theirs(if needed).

bash-2.05b# cat /etc/acpi/acpi_handler.sh
# a sample skeleton for handling ACPI events

if [ $# != 1 ]; then
exit 1
fi
set $*

case "$1" in
           button/power)
                     case "$2" in
                               PWRF) /sbin/init 0
                                         ;;
                               *) logger "ACPI action $2 is not defined"
                                         ;;
                     esac
                     ;;

           *)
                     logger "ACPI group $1 is not defined"
                     ;;
esac
bash-2.05b#

As you can see I highlighted my changes in brown and there wasn't much to it at all. Once you have edited acpi_handler.sh, pressing the power button should now halt the computer.

Great the power button works but what about all those short cut items such as the email and browser buttons you say!
Here is the scoop on that. You might have already noticed that when you were monitering /var/log/messages with the tail command, pushing those buttons may not have caused anything to come up as it did with the power button. This is because of a thing called DSDT. You can find more information about it at acpi.sourceforge.net The bottom line is that you need correct DSDT tables to be made for your computer as many vendors have incorrectly implemented them as mine has. The good news is that you can make your own. The bad news is that you will need some programming experience to do so, as this is all very new stuff and the tools needed are still quite raw.

Feel free to contact me with comments, questions or suggestions; mail to : capaman at gawab dot com