You are not logged in.

#1 2008-02-23 22:36:38

bgc1954
Member
From: Edmonton, AB, Canada
Registered: 2006-03-14
Posts: 1,160

Success on T21 Thinkpad with acpid

Hi all,

After trying most everything I could find here and googling my brains out, I finally got the function buttons to work properly with my T21 Thinkpad.  No special patches or anything required just a new handler.sh script that I borrowed from an article in the gentoo forums--go figure.

#!/bin/sh
# Default acpi script that takes an entry for all actions

set $*

ev_type=`echo "$1" | cut -d/ -f1`

# We have to take special care for events send by ibm/hotkey:
if [ "$ev_type" = "ibm" ]; then
    ev_type=`echo "$1" | cut -d/ -f1`
    event=`echo "$1" | cut -d/ -f2`
    key="$2"\ "$3"\ "$4"
else 
    # Take care about the way events are reported
    ev_type=`echo "$1" | cut -d/ -f1`
    if [ "$ev_type" = "$1" ]; then
        event="$2";
    else
        event=`echo "$1" | cut -d/ -f2`
    fi
fi

case "$ev_type" in
    button)
        case "$event" in
            power)
        logger "acpid: power button pressed; starting shutdown"
#                logger "acpid: received a shutdown request"
                /sbin/init 0
        break
                ;;
        sleep)
        logger "acpid: sleep button pressed; initiating hibernate-ram"
#        logger "acpid: received hibernate request"
        /usr/sbin/pm-suspend
        ;;
            lid)
        logger "acpid: lid event" 
        ;;
        *)
                logger "acpid: action $2 is not defined"
                ;;
        esac
    ;;

# BEGIN customization for ibm/hotkey:
   ibm)
    case "$event" in
        hotkey)
            case "$key" in
                "HKEY 00000080 00001002")
                    logger "acpid: lock button (Fn+F2) pressed"
                    ;;
                 "HKEY 00000080 00001003")
                                logger "acpid: blank screen (Fn+F3) pressed; switching display off"
                    xset dpms force off
                    ;;
                "HKEY 00000080 00001004")
                                logger "acpid: sleep button (Fn+F4) pressed; initiating hibernate-ram"
                    /usr/sbin/pm-suspend
                    ;;
                "HKEY 00000080 00001005")
                                logger "acpid: bluetooth button (Fn+F5) pressed; toggling bluetooth"
                    ;;
                "HKEY 00000080 00001007")
                                logger "acpid: screen toggle button (Fn+F7) pressed"
                    ;;
                
                "HKEY 00000080 0000100c")
                                logger "acpid: hibernate button (Fn+F12) pressed; initiating hibernate"
                     /usr/sbin/pm-hibernate
                    ;;
                
                "HKEY 00000080 00005001")
                    # This is the lid CLOSE event
                    # as of now it is already handled above
                                ;;
                "HKEY 00000080 00005002")
                                # This is the lid OPEN event
                                # as of now it is already handled above
                                ;;
                *)
                    logger "acpid: $ev_type/$event $key is not defined"
                    ;;
            esac
              ;;            
        dock)
                case "$key" in
                "GDCK 00000003 00000001")
                    logger "acpid: Dock eject request"
                    ;;
                    "GDCK 00000003 00000002")
                    logger "acpid: laptop was undocked"
                    ;;
                "GDCK 00000000 00000003")    
                    logger "acpid: laptop was docked"
                    ;;
                *)
                    logger "acpid: $ev_typ $event event $key is not defined"
                    ;;
            esac
            ;;
        bay)
            case "$key" in
                "MSTR 00000003 00000000")
                    logger "acpid: got ultrabay eject request"
                    ;;
                    "MSTR 00000001 00000000")
                    logger "acpid: ultrabay eject lever inserted"
                    ;;
            esac
            ;;
    esac
    ;;    
    *)
        logger "ACPI group $1 / action $2 is not defined"
        ;;
esac

I don't know if everything in here is absolutely necessary.  All I know is after trying every other script I could find, this one works.  The only changes I had to make to the gentoo script was the pm-suspend and pm-hibernate as they use something else.  The Fn+F3 key command was also changed.

I also added resume=/dev/sdaxx (xx is number of your swap partition) to the end of my /boot/grub/menu.lst kernel line and added resume to the hooks section in /etc/mkinitcpio.conf after pata scsi sata.  Then I did a

#mkinitcpio -p kernel26

to rebuild my /boot/kernel26.img.

I added "echo enable,0xffffffff >/proc/acpi/ibm/hotkey" (no quotes) to my /etc/rc.local file and have thinkpad_acpi added to MODULES in /etc/rc.conf.  I think that was all I did but I've been trying so many things over the last couple of days that I might have left out something, but I don"t think so.

I'm very satisfied with Arch on my old IBM laptop now.  Everything I need works.

Edit: I just remembered one other thing but I'm not sure that it is 100% necessary.  I added "options thinkpad_acpi experimental=1" (no quotes) to my /etc/modprobe.conf file.

Another thing you have to do to get pm-suspend and pm-hibernate to work is add these lines in /etc/sudoers :

yourusername     ALL=(ALL) NOPASSWD: /usr/sbin/pm-hibernate
yourusername     ALL=(ALL) NOPASSWD: /usr/sbin/pm-suspend

This will allow you to suspend and hibernate as regular user.

Darn, I just rebooted my laptop and now Fn+F3 doesn't blank the screen--honest, it was working before.  I'll post my progress when I get it working again.

I guess acpi on thinkpads is kind of flaky.  Fn+F3 is working again and I didn't do anything.

Last edited by bgc1954 (2008-02-24 00:20:12)


Time is a great teacher, but unfortunately it kills all its pupils ... - Louis Hector Berlioz

Offline

Board footer

Powered by FluxBB