Gnuru.org
Productive Linux


Subscribe

 Subscribe via Feedburner in a reader

Enter your email address:

Delivered by FeedBurner


Login
Login:
Password:



Don't have an account?
Sign up to Gnuru.org
Forgot your password?

ACPI Thinkpad Scripts
18 August 2005 @ 21:06 BST
by Paul

Here are a couple of ACPI scripts for the Thinkpad. First for sleep. This is almost the same as the one from the ACPI homepage, except the need to start and stop mysql:

#!/bin/sh

# if launched through a lid event and lid is open, do nothing
echo "$1" | grep "button/lid" && grep -q open /proc/acpi/button/lid/LID/state && exit 0

# remove USB 1.1 driver
rmmod uhci_hcd
 
 # sync filesystem and clock
 sync
 /sbin/hwclock --systohc

 # switch to console
 FGCONSOLE=`fgconsole`
 chvt 6
### don't have a radeon tool
# /usr/sbin/radeontool light off

# We have mysql problems
/etc/init.d/mysql stop

 # go to sleep
 echo -n "mem" > /sys/power/state

 # readjust the clock (it might be off a bit after suspend)
 /sbin/hwclock --adjust
 /sbin/hwclock --hctosys

 # reload USB 1.1 driver
 modprobe uhci_hcd

## restart mysql
/etc/init.d/mysql start

 # turn on the backlight and switch back to X
# radeontool light on
 chvt $FGCONSOLE

And for the power button so that it properly shuts down the machine:

#!/bin/sh
# /etc/acpi/powerbtn.sh
# Initiates a shutdown when the power putton has been
# pressed.

if ps -Af | grep -q '[k]desktop' && test -f /usr/bin/dcop
then
    dcop --all-sessions --all-users ksmserver ksmserver logout 0 2 0 && exit 0
else
    /sbin/shutdown -h now "Power button pressed"
fi




Leave a comment:

Are you human?