HARDWARE Dell Latitude D505

From Gentoo Linux Wiki

Jump to: navigation, search
This article is part of the Hardware series.
Laptops TV Tuner Cards Wireless Servers Storage Other Hardware Motherboards Related

Contents

[edit] Overview

This page documents the trials and tribulations that I have suffered whilst trying to install Gentoo Linux on my Dell Latitude d505. This is still a work in progress and I hope to put up on this page what works so that other can have a bit more hair left than I have. I will be constructing this page slowly over time, so if something is missing I either haven't put it in here yet, or haven't figured out how to do it.

[edit] What Works

[edit] The Kernel

I have generally followed the Gentoo Install Instructions to install the Linux kernel except for one major change.- I installed the suspend2-sources kernel.

Note: At the time of writing, the current version of suspend2-sources was 2.6.18-r1

In the following subsections I cover the kernel options I have enabled in order to make it work on the d505

[edit] Graphics

See this HowTo.

[edit] Network

The Latitude is equipped with an Intel Pro 100 Wired Ethernet Card and an Intel Wireless Pro 2200 Wireless networking. There is also the possibility to run Ethernet over Firewire but I don't require this and so never tried to set it up. I run WPA over my wireless network at home, the following options include those required to connect to WPA protected wireless networks. The kernel configuration for networking follows:

Networking  --->
  Networking options  --->
    [*] TCP/IP networking
    [*]   IP: multicasting
    <*>   IP: tunneling
  <*>   Generic IEEE 802.11 Networking Stack
  <*>     IEEE 802.11 WEP encryption (802.1x)
  <*>     IEEE 802.11i CCMP support
  <*>     IEEE 802.11i TKIP encryption
Device Drivers  --->
  Network device support  --->
    [*] Network device support
        Ethernet (10 or 100Mbit)  --->
          [*] Ethernet (10 or 100Mbit)
          ---   Generic Media Independent Interface device support
          [*] EISA, VLB, PCI and on board controllers
          <*>   Intel(R) PRO/100+ support
        Wireless LAN (non-hamradio)  --->
          [*] Wireless LAN drivers (non-hamradio) & Wireless Extensions
          ---   Wireless 802.11 Frequency Hopping cards support
          ---   Wireless 802.11b ISA/PCI cards support
          <M>   Intel PRO/Wireless 2200BG and 2915ABG Network Connection
Cryptographic options  --->
  --- Cryptographic API
  ---   MD5 digest algorithm
  ---   DES and Triple DES EDE cipher algorithms
  ---   AES cipher algorithms
  ---   ARC4 cipher algorithm
  ---   Michael MIC keyed digest algorithm

[edit] PCMCIA

I don't have any PCMCIA cards to test my configuration but nothing appears to complain when I set the following configuration options:

Bus options (PCI, PCMCIA, EISA, MCA, ISA)  --->
  PCCARD (PCMCIA/CardBus) support  --->
    <M> PCCard (PCMCIA/CardBus) support
    <M>   16-bit PCMCIA support
    [*]     Load CIS updates from userspace (EXPERIMENTAL)
    [*]     PCMCIA control ioctl (obsolete)
    ---   32-bit CardBus support
    ---   PC-card bridges
    <M>   CardBus yenta-compatible bridge support

[edit] ACPI

These kernel options are used to configure ACPI and the Suspend2 patches so that not only will suspend to RAM/Disk work properly, but also so that you can automate the shutdown and suspension on certain laptop events. In the Suspend2 configuration you should set the Default resume device name to your swap partition.

Power management options (ACPI, APM)  --->
  [ ] Software Suspend
  [*] Suspend2  --->
        --- Suspend2
        ---   Image Storage (you need at least one allocator)
        [ ]   File Allocator
        [*]   Swap Allocator
        ---   General Options
        (/dev/hda?) Default resume device name
        [ ]   Allow Keep Image Mode
        [*]   Replace swsusp by default
      ACPI (Advanced Configuration and Power Interface) Support  --->
        [*] ACPI Support
        [*]   Sleep States
        <*>   AC Adapter
        <*>   Battery
        <*>   Button
        <*>   Processor
        <*>     Thermal Zone

[edit] Audio

I use the ALSA drivers and the settings in the kernel as listed below:

Device Drivers  --->
  Sound  --->
    <*> Sound card support
        Advanced Linux Sound Architecture  --->
          <*> Advanced Linux Sound Architecture
          <*>   Sequencer support
          <*>   OSS Mixer API
          <*>   OSS PCM (digital audio) API
          [*]     OSS PCM (digital audio) API - Include plugin system
          [*]   OSS Sequencer API
          <*>   RTC Timer support
          [*]     Use RTC as default sequencer timer
          [*]   Verbose procfs contents
                PCI devices  --->
                  <*> Intel/SiS/nVidia/AMD/ALi AC97 Controller

[edit] Touchpad

To get the ALPS touvhpad working nicely with the X Server you need:

Device Drivers  --->
  Input device support  --->
    --- Generic input layer (needed for keyboard, mouse, ...)
    [*]     Provide legacy /dev/psaux device
    <*>   Event interface
    [*]   Mouse  --->
          <*>   PS/2 mouse

[edit] IDE and disk drives

This works well with the following kernel settings

Bus options (PCI, PCMCIA, EISA, MCA, ISA)  --->
  [*] PCI support
      PCI access mode (Any)  --->
Device Drivers  --->
  ATA/ATAPI/MFM/RLL support  --->
    <*> ATA/ATAPI/MFM/RLL support
    <*>   Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support
    ---     Please see Documentation/ide.txt for help/info on IDE drives
    <*>     Include IDE/ATA-2 DISK support
    <*>     Include IDE/ATAPI CDROM support
    ---     IDE chipset support/bugfixes
    <*>     generic/default IDE chipset support
    [*]     PCI IDE chipset support
    [*]       Sharing PCI IDE interrupts support
    <*>       Generic PCI IDE Chipset Support
    [*]       Generic PCI bus-master DMA support
    [*]         Use PCI DMA by default when available
    <*>         Intel PIIXn chipsets support

[edit] USB

USB appears to work flawlessly with the following flags, however I have only tested it with a USB key.

Device Drivers  --->
  SCSI device support  --->
    <*>   SCSI disk support
  USB support  --->
    <*> Support for Host-side USB
    ---   Miscellaneous USB options
    [*]   USB device filesystem
    ---   USB Host Controller Drivers
    <*>   EHCI HCD (USB 2.0) support
    <*>   UHCI HCD (most Intel and VIA) support
    ---   USB Device Class drivers
    <*> USB Mass Storage support
File Systems  --->
  DOS/FAT/NT Filesystems  --->
    <*> MSDOS fs support
    <*> VFAT (Windows-95) fs support
    (850) Default codepage for FAT
    (iso8859-1) Default iocharset for FAT

[edit] Firewire

I don't currently have any Firewire devices but nothing complains when I set:

Device Drivers  --->
  IEEE 1394 (FireWire) support  --->
    <*> IEEE 1394 (FireWire) support
    <*>   OHCI-1394 support

[edit] Modem

I have the modem disabled in my laptop - does anybody still use it...

[edit] Other Kernel Settings

This section contains other things you might want to set for the kernel before you build it but don't obviously fit into any of the sub-sections listed above:

Loadable module support  --->
  [*] Enable loadable module support
  [*]   Module unloading
  [*]   Automatic kernel module loading
Processor type and features  --->
  [ ] Symmetric multi-processing support
      Subarchitecture Type (PC-compatible)  --->
      Processor family (Pentium M)  --->
Device Drivers  --->
  Parallel Port Support  --->
    <*> Parallel port support
    <*>   PC-style hardware
    [*] IEEE 1284 transfer modes
  Character devices  --->
    Serial drivers  ---> 
      <*> 8250/16550 and compatible serial support
      (4)   Maximum number of 8250/16550 serial ports
      (4)   Number of 8250/16550 serial ports to register at runtime
    <*> Parallel printer support

[edit] Portage, make.conf and Build Profiles

For everything to install and build properly, you need to configure your build profile and set up make.conf

[edit] Build Profile

I link to the Desktop sub-profile for the 2006.1 Gentoo profiles. The result of ls -l /etc | grep make.profile on my laptop looks like this:

lrwxrwxrwx  1 root root    54 Mar 21 19:47 make.profile -> /usr/portage/profiles/default-linux/x86/2006.1/desktop

[edit] make.conf

The most important fields to add to this file are the USE flags and the drivers that are required to be installed for Xorg. Here are the relevant lines of my make.conf file:

USE="adc asf bash-completion -directfb fbcon fbsplash ffmpeg ftp gnome imap java javascript mplayer nsplugin opengl pdf qt3support tetex threads xinerama"
INPUT_DEVICES="keyboard mouse synaptics"
VIDEO_CARDS="i810"

I have more USE flags specified personally, I only include the ones you should have to make-it-work.

[edit] GRUB Configuration

I use GRUB as my boot loader. The configuration lines required to boot the kernel are:

title Gentoo Linux (2.6.18)
root (hd?,?)
kernel /boot/kernel-2.6.18 root=/dev/hda? video=vesafb:mtrr,ywrap,1024x768-32@60

Replace partition information as required.

Note: You need to have a BIOS A09 (or later) installed on the Latitude to access higher resolutions and pixel depths. With a 1MB Graphics Aperture the only resolutions available are 1024x768-8, 800x600-8, 640x480-8, 640x480-16.

Higher graphics depths are available with an 8MB Graphics Aperture.

Resolution 1400x1050 is not available at all. 1280x1024 is a valid mode but does not work so don't select it.

[edit] Frame Buffer

Lets start by getting the Frame Buffer Working. We already have support for the frame buffer installed and, if you have rebooted since recompiling and installing the kernel, are probably already looking at the screen at a higher resolution. First we need to install our splash theme and the framebuffer splash utilities.

emerge splashutils splash-themes-livecd

There are other splash themes - or you can create your own - but I like the livecd theme so will use that here.

The first step is to create an initrd image with our splash theme installed and put it in /boot so that it can be loaded before the kernel - we get a nice background as early as possible:

splash_geninitramfs -g /boot/fbsplash-livecd-1024x768 -r 1024x768 livecd

Change the resolution and initrd filename if you are running at lower resolution.

We then need to specify in our grub.conf file to load the initrd image and to specify our preferred splash options on the kernel boot line. I have two boot up options in my grub.conf to allow me to boot silently normally (looks nice) and verbosely if I'm troubleshooting something.

File: /boot/grub/grub.conf (excerpts)

##########
title Gentoo Linux (2.6.18)
root (hd0,?)
kernel /boot/<kernel_name> root=/dev/hda? video=vesafb:mtrr,ywrap,1024x768-32@60 splash=silent,theme:livecd-2006.1 quiet CONSOLE=/dev/tty1
initrd /boot/fbsplash-livecd-1024x768
##########
title Gentoo Linux (2.6.18) - Verbose
root (hd0,?)
kernel /boot/<kernel_name> root=/dev/hda? video=vesafb:mtrr,ywrap,1024x768-32@60 splash=verbose,theme:livecd-2006.1
initrd /boot/fbsplash-livecd-1024x768

Finally we need to start the Frame Buffer splash at system start-up so it runs on all consoles:

rc-update add splash boot

[edit] Xorg

[edit] Audio

Relatively simple. First install the helper programs.

emerge alsa-utils alsa-lib

Then start automatically at system boot

rc-update add alsasound boot

We need to start it once to initialise the card

/etc/init.d/alsasound start

And then un-mute the sound card and any playback/recording sources you want to use

alsamixer

The next time you reboot the sound card settings will be saved for subsequent reboots.

[edit] Networking

This is a laptop, as such the laptop will often be operating where:

  • There is no networking
  • There is only wireless network access
  • There is only fixed wired network connectivity
  • There are both types of network

We want to ensure that everything boots up properly under all circumstances and that it is easy to use generically.

[edit] The wired Ethernet port

I choose to use netplug to manage the auto-detection of a cable being plugged into my Ethernet port and to subsequently bring the interface up and down:

emerge netplug

We need to ensure that the Ethernet (eth0) is not automatically brought up at system boot

rc-update del net.eth0

[edit] Wireless Networking

While the ipw2200 driver is now available as a module, there are a number of problems still to resolve.

  • The module will not start unless the wireless card firmware is available
  • The module should be configured to autoload

We need to run:

emerge net-wireless/ipw2200-firmware
echo "ipw2200" >> /etc/modules.autoload.d/kernel-2.6

The default tools do not allow us to associate with a WPA protected AP, to do this we need to install wpa_supplicant. I also install wireless-tools to get access to the provided utilities.

emerge net-wireless/wpa_supplicant net-wireless/wireless-tools

Next we need to configure wpa_supplicant to use our access point. My example configuration below is for my situation:

  • I allow all users (of the laptop) to access wpa_supplicant using a client and to update the configuration file when a new access point is to be used
  • My Home WAP is protected using WPA-PSK and TKIP, obviously these are not my SSID and passphrase
  • My Work WAP is an open access point. I then need to use the Cisco VPN clientto get to the Internet

The sample wpa_supplicant.conf file provided during the install has many examples on how to configure wireless APs that you can use to suit your purposes.

File: /etc/wpa_supplicant/wpa_supplicant.conf

update_config=1
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=users
eapol_version=1
ap_scan=1
fast_reauth=1
##########
network={
  ssid="HOME_XXXXX"
  proto=WPA
  key_mgmt=WPA-PSK
  pairwise=TKIP
  group=TKIP
  psk="My_SeCrEt_PaSsPhRaSe"
  priority=1000
}
##########
network={
  ssid="WORK_XXXXX"
  key_mgmt=NONE
  priority=1000
}

Since wpa_supplicant will correctly associate with suitable APs and no routes will exist until this has been done, I allow the rc scripts to automatically bring the interface up at system boot:

Finally we need to configure the network interfaces, the example /etc/conf.d/net provided below assumes that all the networks you connect to provide DHCP:

  • We ensure that wpa_supplicant is automatically loaded as required
  • We price a higher routing metric on the Wireless LAN so that traffic is routed out the Wired Ethernet if it is available

File: /etc/conf.d/net

modules=("wpa_supplicant")
wpa_supplicant_eth1=("-Dwext")
##########
config_eth0=("dhcp")
metric_eth0="100"
##########
config_eth1=("dhcp")
metric_eth1="200"

[edit] Suspend to RAM/Disk

Suspending to RAM and Disk took quite a while to get sorted out, there are multiple steps that were required.

[edit] Installing Helper Applications

The Suspend2 helper applications, particularly the hibernate script and the user interface tools need to be installed. On my system they were installed automatically when I emerged the suspend2-sources. The appropriate tools are:

emerge suspend2-userui   <version 0.6.4-r1 at time of writing>
emerge hibernate-script  <version 1.94-r5 at time of writing>

For suspend to RAM to function correctly you also need to install vbetool

emerge vbetool           <version 0.7 at time of writing>

[edit] Configuring hibernate

Suspending to RAM and disk is done running (respectively):

#> hibernate
#> hibernate-ram

However we need to configure hibernate (/etc/hibernate/*) before everything will work properly.

Emerging hibernate-script provides most of the required configuration, I found that I had to prepend the following lines to the configuration files.

For suspend2.conf I had to re-specify the swap partition to use. The two ProcSetting options specify that hibernation should be accompanied by the FBSplash screen and to use the old method of storing pages. The last of these settings appears to be required if you run KDE as otherwise you will get sporadic errors trying to stop the kswapd process - apparently a problem currently being looked at.

File: /etc/hibernate/suspend2.conf

SuspendDevice swap:/dev/hda?
ProcSetting userui_program /sbin/suspend2ui_fbsplash
ProcSetting full_pageset2 1

For common.conf we specify to lock any open KDE sessions prior to suspending. It is also necessary to re-launch 915resolution so that the Video BIOS is properly re-programmed for 1400x1050 resolution.

File: /etc/hibernate/common.conf

FBSplash on
LockKDE on
Runi915resolution yes

[edit] More hibernate bugs

Even though the hibernate configuration files specify to not use encryption AND to use the full_pageset2 option, it appears that it doesn't work.

[edit] Encryption

The Suspend2 pages say that by default encryption is not enabled and it is also disabled in the scripts. yet I have found that on system boot the contents of /sys/power/suspend2/encryption/enabled is always 1. Any attempt to hibernate will fail with an error message stating that encryption is enabled but not configured. This will then cause /sys/power/suspend2/encryption/enabled to be reset to 0 whereupon suspension will properly occur on the next attempt.

[edit] Full_pageset2

As for encryption, I found that even setting this in the /etc/hibernate/* configuration caused the kswapd problem to still occur and that it would need to be manually set.

[edit] Fixing the bugs

At least until it is sorted out properly, I needed to edit /etc/conf.d/local.start to read.

File: /etc/conf.d/local.start

echo "     Fixing Suspend2 bugs..."
echo 0 > /sys/power/suspend2/encryption/enabled
echo 1 > /sys/power/suspend2/full_pageset2

[edit] Fixing the Frame Buffer Splash during reboot

The final step involves installing the hibernate user interface programs for the frame buffer splash into the initrd image loaded at system boot. This allows the frame buffer splash to work nicely at the start of system boot giving us a nice display. I've created the following script that when executed from the command line with the name of the initrd file will extract the contents of the initrd file, install the suspend2ui_fbsplash helper utility, recompress the initrd file and replace the original file with the modified one. I typically would run this like:

./fix_initrd.sh /boot/fbsplash-livecd-1400x1050

Script: fix_initrd.sh

#!/bin/sh
SUSPEND2_FBSPLASH=`which suspend2ui_fbsplash`

##########
uncompress_initrd () {
  echo "  Extracting ($1) to ($2)..."
  pushd $2 > /dev/null
  gunzip -c $1 | cpio -idm --quiet -H newc
  popd > /dev/null
}

##########
install_suspend2 () {
  echo "  Installing suspend2 fbsplash helper to ($1)..."
  cp $SUSPEND2_FBSPLASH $1/sbin/
}

##########
compress_initrd () {
  echo "  Renaming ($1) to ($1.old)..."
  mv $1 $1.old
  echo "  Compressing ($1)..."
  pushd $2 > /dev/null
  find . | cpio --quiet --dereference -o -H newc | gzip -9 > $1
  popd > /dev/null
}

##########
echo "fix_initrd - Add suspend2 fbsplash helper to initrd script"
echo
echo initrd: $1

mkdir tmp
uncompress_initrd $1 tmp
install_suspend2 tmp
compress_initrd $1 tmp
rm -fR tmp

[edit] ACPI - Automating Laptop Functionality

Some of the features specified above should behave automatically, features like:

  • Suspend to RAM/Disk if the lid is closed or the power button pressed
  • Changing CPU frequency management based on how the laptop is powered
  • Shutting down when the battery gets too low

This is all managed via the ACPID daemon, the program is installed via

emerge acpid

Once installed you should configure it to automatically start at system boot:

rc-update add acpid default

[edit] Scripting ACPID

I choose not to configure acpid to run different scripts with different events. I leave the default event handler (/etc/acpi/events/default) running the default event handling script (/etc/acpi/default.sh). I modify the scripts to manage what I want them to do:

First we modify /etc/acpi/default.sh. We parse the passed kernel ACPI event and if it is a button event - either power, lid or sleep (Fn-Esc) - then we pass the event to the /etc/acpi/button.sh script to handle. All other events are handled using the original default handler - do nothing

#!/bin/sh
# /etc/acpi/default.sh
set $*

group=${1/\/*/}
action=${1/*\//}
device=$2
id=$3
value=$4

log_unhandled() {
  logger "ACPI event unhandled: $*"
}

case "$group" in
  button)     /etc/acpi/button.sh $action $device $id $value
              ;;

  ac_adapter) case "$value" in
                # Add code here to handle when the system is unplugged
                # (maybe change cpu scaling to powersave mode)
                #*0)
                #       cpufreq-set -g powersave
                #       ;;

                # Add code here to handle when the system is plugged in
                # (maybe change cpu scaling to performance mode)
                #*1)
                #       cpufreq-set -g performance
                #       ;;

                *)      log_unhandled $* ;;
              esac
              ;;

  *)            log_unhandled $* ;;
esac

Of more interest is the /etc/acpi/button.sh script. We want this script to do the following:

  • Power button pressed - run hibernate to suspend-to-disk
  • Sleep (Fn-Esc) pressed - run hibernate to suspend-to-disk
  • Lid closed - Suspend-to-RAM. Set an ACPI alarm to wake up the laptop after a timeout period. If the user has re-activated the laptop before then cancel the alarm. If they haven't, then run suspend-to-disk (this simulates Windows behaviour)
#!/bin/sh
################################################################################
# File: /etc/acpi/button.sh                                                    #
################################################################################
# This script is executed when any ACPI button event occurs.  We separate the  #
# ACPI events to simplify debugging these scripts.  The script is called with  #
# four parameters)                                                             #
#  1) action - Which button action has occured                                 #
#  2) device - The device name                                                 #
#  3) id     - The ACPI event ID                                               #
#  4) value  - The ACPI event value                                            #
################################################################################
# The laptop has three unique buttons (power, sleep and lid)                   #
# For power and sleep, we want to do a suspend-to-disk                         #
# For the lid button, we want to suspend-to-ram, then - if the laptop hasn't   #
# been re-opened within the timeout period - wake up and suspend-to-disk       #
################################################################################

##########
set $*

##########
# Set variables to store passed in parameters
##########
ACPI_ACTION=$1
ACPI_DEVICE=$2
ACPI_ID=$3
ACPI_VALUE=$4

##########
# Global variables
#
# PROC_ACPI          - The base location of the ACPI information
# AC_STATUS_FILE     - File containing ACPI status of the power source (AC/Battery
# TIMEOUT_AC         - Minutes to delay shutdown if we are running on AC
# TIMEOUT_BAT        - Minutes to delay shutdown if we are running on battery
# HIBERNATE_CMD      - Location of hibernate (shutdown) script
# HIBERNATE_RAM_CMD  - Location of hibernate-ram (suspend-ram) script
##########
PROC_ACPI="/proc/acpi"
AC_STATUS_FILE="$PROC_ACPI/ac_adapter/AC/state"
TIMEOUT_AC=30
TIMEOUT_BAT=10
HIBERNATE_CMD=`which hibernate`
HIBERNATE_RAM_CMD=`which hibernate-ram`

##########
# Log the specified parameter into the system log
##########
log_info () {
  logger "ACPI: $1"
}

#########
# Called when the lid has closed to suspend to RAM
#
# - Check if we are on ac or battery power and set TIMEOUT to how many minutes we
#   need to delay the final hibernation (to disk)
# - Turn the screen off (not just black)
# - Set the ACPI alarm to wake up from sleep after TIMEOUT minutes
#   o This alarm does nothing if we have already woken up (open lid)
#   o Will cancel the suspend to RAM if the TIMEOUT has passed with no user wakeup
# - Actually suspend to RAM
#   o The script will stop here as the suspension takes place, when we wake up w
e
#     will resume from here - regardless if we were woken by user interaction (open
#     lid/power button) or via ACPI alarm
# - What is the lid status
#   o If closed or unknown, save the battery and immediately suspend
#   o If open the user wants to resume using laptop, cancel the pending ACPI alarm
#     and resume, everything will(should) be alright
#########
suspend_to_ram () {
  AC_STATUS=`cat $AC_STATUS_FILE`
  case "$AC_STATUS" in
    *on-line)  log_info "Power Status (AC)"
               TIMEOUT=$TIMEOUT_AC
               ;;
    *off-line) log_info "Power Status (Battery)"
               TIMEOUT=$TIMEOUT_BAT
               ;;
    *)         log_info "ERROR - Unknown power AC status ($AC_STATUS)"
               ;;
  esac

  log_info "Turning off screen"
  vbetool dpms off

  log_info "Scheduling wakeup in $TIMEOUT minutes"
  echo `date -d "$DELAY minutes" "+%Y-%m-%d %H:%M:%S"` > /proc/acpi/alarm

  log_info "Suspending to RAM"
  $HIBERNATE_RAM_CMD

  log_info "Waking up - Checking lid status..."
  case `cat $PROC_ACPI/button/$ACPI_ACTION/$ACPI_DEVICE/state` in
    *open)   log_info "Lid opened - cancel /proc/acpi/alarm"
             echo `date "+%Y-%m-%d %H:%M:%S"` > /proc/acpi/alarm
             ;;
    *closed) log_info "Lid still closed - Hibernating now..."
             $HIBERNATE_CMD
             ;;
    *)       log_info "ERROR(Unknown lid state) - Hibernating now..."
             $HIBERNATE_CMD
             ;;
  esac
}

##########
# This is the actual script
#
# - If it is NOT an ACPI "button" event log an error message and terminate,
#   something is wrong in the acpid configuration
# - Check which button has been pressed ($action)
#   o "power" and "sleep" trigger an immediate suspend
#   o "lid" requires further checks
#     - If the lid is (just) closed call suspend_to_ram()
#     - If the lid is (just) opened this is abnormal, we turn on the screen
#       display just in case
##########
case "$ACPI_ACTION" in
  power) log_info "Power Button pressed" 
        $HIBERNATE_CMD
         ;;
  sleep) log_info "Sleep Button pressed"
         $HIBERNATE_CMD
         ;;
  lid)   case `cat $PROC_ACPI/button/$ACPI_ACTION/$ACPI_DEVICE/state` in
           *closed) log_info "Lid closed"
                    suspend_to_ram
                    ;;
           *open)   log_info "Lid opened"
                    log_info "Turning on screen (just in case)"
                    vbetool dpms on
                    ;;
           *)       log_info "ERROR - Lid event, unknown lid state"
                    ;;
         esac
         ;;
  *)     log_info "ERROR - Unknown ACPI button event ($action - $device)"
         ;;
esac

[edit] Links

Personal tools