[ltp] [T42] How implement ACPI, i'm lost...

morpheus linux-thinkpad@linux-thinkpad.org
Mon, 24 Jan 2005 11:58:24 -0500


Also, I wrote a HOWTO and posted it on this list a few months ago, you
should search the archives before posting a basic question.
Try searching GOOGLE with site:linux-thinkpad.org ACPI
Here is my HOWTO:

Thinkpad ACPI and Function Key HOWTO by morpheus
-------------------------------------------------
First, compile and install ibm-acpi, which you can get from http://ibm-
acpi.sourceforge.net/

Click on README for installation details.

After install, don't forget to do:
# modprobe ibm_acpi
# echo enable > /proc/acpi/ibm/hotkey
# echo 0xffff > /proc/acpi/ibm/hotkey
(where ffff should be replaced by the key mask, as described in the
README.)
Also, if you want it to automatically enable in Fedora all the time,
edit /etc/rc.d/rc.local and add the lines above to this file.

The hard part here is that the README doesn't tell you how to configure
acpi events themselves.

You must create config files for each event in the
directory /etc/acpi/events.
There is already a file there called "sample.conf" which you can copy to
Fn-F3.conf, or Fn-F4.conf (make as many as you need).
Then just edit the files.  There are only two lines:
event=
action=
For "event=" use the following:

Key Event Line
----- -------------------------------------------
Fn-F3 event=ibm/hotkey HKEY 00000080 00001003
Fn-F4 event=ibm/hotkey HKEY 00000080 00001004
Fn-F5 event=ibm/hotkey HKEY 00000080 00001005
Fn-F7 event=ibm/hotkey HKEY 00000080 00001007
Fn-F12 event=ibm/hotkey HKEY 00000080 0000100c

For more events, run
# tail -f /var/log/acpid
Then press keys and watch what event appears.

For the "action=" line you can run any command.  However, it is easier
to manage if you create scripts in /etc/acpi/actions which are named the
same as your config files.  For example:
Fn-F3.sh
Fn-F4.sh
These should contain the commands you want to run.  Don't forget to make
them executable!!
# chmod a+x Fn-F3.sh

For the T42p, the ibm-acpi /proc/acpi/ibm/video cannot be used to turn
the LCD backlight on and off.  Fortunately there is a package called
radeontool that can do this.  You can apt-get it or get an RPM from
rpm.pbone.net.

Next, save the following script as /etc/acpi/actions/Fn-F3.sh

#!/bin/bash
if [ -f /etc/acpi/actions/lightoff ]; then
radeontool light on
rm /etc/acpi/actions/lightoff
else
radeontool light off
touch /etc/acpi/actions/lightoff
fi

This script will toggle your backlight on and off.  If you create a
config file in /etc/acpi/events/ that contains the following:

event=ibm/hotkey HKEY 00000080 00001003
action=sh /etc/acpi/actions/Fn-F3.sh

You can now toggle the backlight with the Fn-F3 key.

As for the other keys, you can just copy /etc/acpi/events/Fn-F3 to files
called Fn-F4, Fn-F5, etc., then edit them so the event and action lines
match the key number.

Now, all you have to do is create scripts in /etc/acpi/actions that
match the key numbers.

Here are mine (Fn-F3 is above):

/etc/acpi/actions/Fn-F4.sh -- For Suspend
#!/bin/bash
echo 3 > /proc/acpi/sleep

/etc/acpi/actions/Fn-F5.sh -- For Bluetooth
#!/bin/bash
#!/bin/bash
grep enabled /proc/acpi/ibm/bluetooth
if [ "$?" == "0" ]; then
 echo disable > /proc/acpi/ibm/bluetooth
else
 echo enable > /proc/acpi/ibm/bluetooth
fi

/etc/acpi/actions/Fn-F7.sh -- Since the xorg radeon driver won't allow
you to switch displays dynamically, you can use this for something else.
I use it to switch the wireless lan radio on and off:
#!/bin/bash
lsmod | grep ath_pci
if [ "$?" == "0" ]; then
 modprobe -r ath_pci
 modprobe -r ath_hal
 modprobe -r wlan
else
 modprobe wlan
 modprobe ath_hal
 modprobe ath_pci
fi

/etc/acpi/actions/Fn-F12.sh -- For Hibernate
#!/bin/bash
echo 4 > /proc/acpi/sleep

Be careful when editing these files if you use an editor like kedit that
automatically makes backups like Fn-F7~. If these are in
your /etc/acpi/events directory, they will be loaded by acpi (which
loads all files in that directory that don't begin with a period). To be
sure, do a:
# rm /etc/acpi/events/*~

Finally, before you test if the buttons work, you need to reload the
config files by typing:
# /etc/init.d/acpid restart

Note, in order for sleep and hibernate to work, you need to have acpi
set up properly.  Here's a good resource for more info:
http://x1.cs.umd.edu/t42p.html

Good luck!!

On Mon, 2005-01-24 at 11:31 +0100, Tino Keitel wrote:
> On Mon, Jan 24, 2005 at 10:39:01 +0100, sebastiengrillot wrote:
> > Hello,
> > First of all sorry for my english...
> > I have just one question : how implement ibm_acpi on an Ibm laptop
> > and a GNU/Linux computer (a gentoo)... I think it's a sily question
> > for a lot of them but i didn't know what doing... i have ibm_acpi in
> > the module autoloarder on the start up of my computer but i didn't
> > know use them...
> > can someonbe could help me ?
> 
> How about reading the docs?
>    
> http://ibm-acpi.sourceforge.net/README
>    
> Regards,
> Tino