Geek Minute

All that is geek...

About

About

Contact Info

Me

Previous Posts

News Letter

Google Groups
Email:

Thursday, October 13, 2005

Back to Linux

Over the past few days I have been installing Gentoo on my laptop. I have left a small partition for Windows XP and Visual Studio development, but I am running in Linux full time now. It is great to be back!! This afternoon I set the goal of getting my lcd light to turn off when the lid is closed and to make use of my power and sleep buttons. I have a Dell Inspiron 600M. It's a great little laptop.

To make use of any of this, you will need to have acpi enabled as part of your kernel.
Next, you have to install the acpi deamon to watch for the different events to occur.

# emerge acpid

You also will want it to load on boot...

#rc-update add acpid default

Now, I wanted the power button to shut down my computer and the sleep button to put it into suspend-to-disk (hibernate). Being a college student, I am also bouncing from place to place to hibernate is a must.

All the files we will need to edit as located in /etc/acpi/

#cd /etc/acpi

The files in events/ are set up to catch certain or all acpi triggering events. Upon install, there is a default event that catches all events. It then calls the script /etc/acpi/default.sh. I added made my changes to this file. At first I was making seperate scripts for each event but I figured, what's the point so I combined them all afterwards.

My default.sh:

#!/bin/sh
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-power/acpid/files/acpid-1.0.4-default.sh,v 1.1 2005/03/15 19:15:53 ciaranm Exp $

# Default acpi script that takes an entry for all actions

set $*

group=${1/\/*/}
action=${1/*\//}

case "$group" in
button)
case "$action" in
power) shutdown -h -t secs 0
;;
sleep)
echo -n disk > /sys/power/state
;;
lid)
state=$(echo `cat /proc/acpi/button/lid/LID/state | awk '/state:/{print $2}'`)

if [ "$state" = "closed" ]; then
radeontool light off
else
radeontool light on
fi
;;

*) logger "ACPI action $action is not defined"
;;
esac
;;

*)
logger "ACPI group $group / action $action is not defined"
;;
esac
For each button there is a command or series of commands run to react to the button being pressed.

Power and sleep are the simplest with one line command results. The lid button event has to check the current state of the lid by checking /proc/acpi/button/lid/LID/state for the current state and acting acordingly.

Posted by Jon Heizer at 4:09 PM

0 Comments:

Post a Comment

<< Home




Search

Google
Web GeekMinute.Com

Subscribe

Xml Feed

Computers Blog Top Sites


Get Chitika eMiniMalls





Creative Commons License
This work is licensed under a Creative Commons License.