[ltp] HOWTO - acpid and ibm-acpi on a T42p
morpheus
linux-thinkpad@linux-thinkpad.org
Tue, 14 Dec 2004 18:15:02 -0500
Hi,
After lots of trial and error, I managed to get ibm-acpi working with
most of the Fn-Fx keys on my T42p. Here is a simple HOWTO:
First, compile and install ibm-acpi, which you can get from http://ibm-
acpi.sourceforge.net/
Click on README for installation details.
Don't forget to do:
# modprobe ibm_acpi
to enable the module after installation. Also, if you want it to
automatically enable in Fedora all the time, edit /etc/rc.d/rc.local and
add the line 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!!