Running Slackware Linux on Thinkpad T61

ACPID and HotKeys Configuration in Slackware Linux for ThinkPad T61

Author: Cowyn Li

Make sure ACPI is enabled in the kernel. For 2.6.x kernel, check as below:

  --- ACPI (Advanced Configuration and Power Interface) Support
  [*]   Deprecated /proc/acpi files
  [*]   Deprecated power /proc/acpi directories
  [*]   Future power /sys interface
  [*]   Deprecated /proc/acpi/event support
  <M>   AC Adapter
  <M>   Battery
  <M>   Button
  <M>   Video
  <M>   Fan
  -*-   Dock
  <M>     Removable Drive Bay (EXPERIMENTAL)
  <M>   Processor
  <M>     Thermal Zone
        
  $ cat ~/.Xmodmap
  keycode 144 = XF86AudioPrev
  keycode 153 = XF86AudioNext
  keycode 159 = XF86LaunchA
  keycode 160 = XF86AudioMute
  keycode 162 = XF86AudioPlay
  keycode 164 = XF86AudioStop
  keycode 174 = XF86AudioLowerVolume
  keycode 176 = XF86AudioRaiseVolume
  keycode 227 = F35
  keycode 233 = XF86Forward
  keycode 234 = XF86Back
      

Store the ACPI event files in /etc/events directory, and the action scripts in /etc/actions directory.

They could be merged into one file.

  $ cat /etc/acpi/events/lockscreen
  event=ibm/hotkey HKEY 00000080 00001002
  action=/etc/acpi/actions/lockscreen.sh

  $ cat /etc/acpi/actions/lockscreen.sh
  #!/bin/sh
  xlock -display :0
        
  $ cat /etc/acpi/events/sleep
  event=ibm/hotkey HKEY 00000080 00001004
  action=/etc/acpi/actions/sleep.sh

  $ cat /etc/acpi/actions/sleep.sh
  #!/bin/sh
  # sleep.sh test script for measuring power drain during suspend-to-ram with ACPI

  #if ! grep -q '^charging state:.*discharging' /proc/acpi/battery/$BATTERY/state; then
  #   echo 'Not running on battery power, did you forget to disconnect the charger?'
  #   exit 1
  #fi

  if [ "$UID" != "0" ]; then
    echo 'This script can only be run by root.'
    exit 1
  fi

  # remove USB for external mouse before sleeping
  if lsmod | grep '^usbhid' >/dev/null ; then
    /sbin/modprobe -r -s usbhid
  fi
  if lsmod | grep '^uhci_hcd' >/dev/null ; then
    /sbin/modprobe -r -s uhci_hcd
  fi
  if lsmod | grep '^ehci_hcd' >/dev/null ; then
    /sbin/modprobe -r -s ehci_hcd
  fi

  # save system time
  hwclock --systohc

  # check to turn off think-light
  if egrep 'status.*on' /proc/acpi/ibm/light ; then
    echo off > /proc/acpi/ibm/light
  fi

  # go to sleep
  if [ -e /proc/acpi/sleep ]; then
    sleep 2 && echo 3 > /proc/acpi/sleep
  else
    sleep 2 && echo -n mem > /sys/power/state
  fi

  # restore USB support 
  if !(lsmod | grep '^ehci_hcd') >/dev/null ; then
    /sbin/modprobe -s ehci_hcd
  fi
  if !(lsmod | grep '^uhci_hcd') >/dev/null ; then
    /sbin/modprobe -s uhci_hcd
  fi
  if !(lsmod | grep '^usbhid')   >/dev/null ; then
    /sbin/modprobe -s usbhid
  fi

  # restore system time
  hwclock --hctosys
        
  $ cat /etc/acpi/events/powerbtn
  event=button/power PWRF 00000080 .*
  action=/etc/acpi/actions/powerbtn.sh

  $ cat /etc/acpi/actions/powerbtn.sh
  #!/bin/sh
  DISPLAY=':0.0' xmessage -buttons Shutdown:0,Cancel:1 -timeout 7 -default Shutdown -title \
    "Shutting Down" -center "  Shutdown the computer?  " && shutdown -h now
        
  $ cat /etc/acpi/events/battery
  event=ibm/hotkey HKEY 00000080 00001003
  action=/etc/acpi/actions/battery.sh

  $ cat /etc/acpi/actions/battery.sh
  #!/bin/sh
  INFO=/proc/acpi/battery/BAT0/state
  cat $INFO|xmessage -center -file -
        
  $ cat /etc/acpi/events/thinkvantage
  event=ibm/hotkey HKEY 00000080 00001018
  action=/etc/acpi/actions/thinkvantage.sh

  $ cat /etc/acpi/actions/thinkvantage.sh
  #!/bin/sh
  fluxbox-remote rootmenu
        
  $ cat /etc/acpi/events/wireless
  event=ibm/hotkey HKEY 00000080 00001005
  action=/etc/acpi/actions/wireless.sh

  $ cat /etc/acpi/actions/wireless.sh
  #!/bin/sh
  # Toggle wireless interfaces

  function bt {
    INFO=/proc/acpi/ibm/bluetooth
    if egrep -q 'status.*enabled' $INFO; then
      echo disabled > $INFO
      if [ -x /etc/rc.d/rc.bluetooth ]; then /etc/rc.d/rc.bluetooth stop;fi
    else
      echo enable > $INFO
      if [ -x /etc/rc.d/rc.bluetooth ]; then /etc/rc.d/rc.bluetooth start;fi
    fi
  }

  function wlan {
    if ifconfig|egrep -q 'wlan'; then
      ifconfig wlan0 down
    else
      ifconfig wlan0 up
    fi
  }

  DISPLAY=':0.0' xmessage -buttons Yes:0,No:1 -default No -title "Choice" \
    -center "  Toggle Bluetooth Interface?  " && bt
  DISPLAY=':0.0' xmessage -buttons Yes:0,No:1 -default No -title "Choice" \
    -center "     Toggle Wlan Interface?    " && wlan
        

Problems

The fn-brightness (Fn + Home/End) hotkey won't work. I don't change the brightness from time to time, so currently I just added this line into rc.local:

echo 6 > /sys/class/backlight/acpi_video1/brightness

The Wlan led won't work. The wireless card works.

Since kernel 2.6.26, the two issues above have been solved. Wlan led is supported since kernel 2.6.26. I have no idea about since when the brightness keys are supported.

The volume keys won't work.

I use keys defined in fluxbox to control the volume. See Fluxbox volume keys configuration.

Reference:

Back to Index of Running Slackware Linux on ThinkPad T61.


Valid XHTML | ©2010 dOtImes.cOm, All rights reserved. | Creative Commons | Powered by Slackware, Nginx. Posted and Maintained by Cowyn Li
Last Update: Monday, 2008-11-19, 18:35, UTC+8.