[ltp] IBM_ACPI and Powersaved for SuSE 9.2
Frank Fiene
linux-thinkpad@linux-thinkpad.org
Thu, 30 Dec 2004 21:36:04 +0100
--Boundary-00=_0aG1BMu312I8MD0
Content-Type: text/plain;
charset="iso-8859-15"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline
Hey guys.
I've created a script for the powersaved in SuSE 9.2 and ibm-acpi
module.
It is based on
http://www.iiv.de/schwinde/buerger/tremmel/downloads/acpi_9.2/kaffeine0.4/acpi_hotkeys_ASUS_M6842NW
from Manfred Tremmel and Stefan Seyfried and the scripts for acpid
from morpheus here in the mailing list.
To enable own scipts in powersaved, i had to add the name of a script
without path into the variable POWERSAVE_EVENTS_OTHER
in /etc/sysconfig/powersave/events. For example ibm_acpi.sh.
I created the file ibm_acpi.sh in /usr/lib/powersave/scripts.
And this works for me. Any comments?
Regards, Frank.
--
uniorg Solutions GmbH - Märkische Strasse 237 - 44141 Dortmund
ffiene@veka.com - Tel:0231-9497-262
--
Ein Unternehmen der uniorg-Gruppe
--Boundary-00=_0aG1BMu312I8MD0
Content-Type: application/x-shellscript;
name="ibm_acpi.sh"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="ibm_acpi.sh"
#!/bin/bash
# ibm_acpi.sh
# Frank Fiene
# Based on the scripts of Manfred Tremmel and Stefan Seyfried
#
echo "ibm_acpi $*"| \
logger
# first get helper functions (e.g. DEBUG, load_scheme, ...)
. "/usr/lib/powersave/scripts/helper_functions"
PATH=/bin:/usr/bin:/sbin # be paranoid, we're running as root.
export PATH
ret=0
MYNAME=${0##*/} # basename $0
if [ $# -ne 3 ] ; then # something wicked happened
DEBUG "something wicked happened. number of arguments: $#, arguments: '$*'" ERROR
exit 1
fi
run_on_xserver() {
get_x_user
su $X_USER -c "export DISPLAY=$DISP;$1"
}
toggle_bluetooth() {
if grep -q enabled /proc/acpi/ibm/bluetooth; then
echo "Disable Bluetooth" | logger -t $MYNAME
echo disable > /proc/acpi/ibm/bluetooth
exit 0
else
echo "Enable Bluetooth" | logger -t $MYNAME
echo enable > /proc/acpi/ibm/bluetooth
exit 0
fi
}
toggle_wlan() {
if grep -q ath_pci /proc/modules; then
echo "Disable WLAN" | logger -t $MYNAME
modprobe -r ath_pci
modprobe -r ath_hal
modprobe -r ath_rate_onoe
modprobe -r wlan
exit 0
else
echo "Enable WLAN" | logger -t $MYNAME
modprobe wlan
modprobe ath_hal
modprobe ath_pci
exit 0
fi
}
toggle_light() {
RADEONTOOL='/usr/bin/radeontool'
status=`$RADEONTOOL light|sed s/The\ radeon\ backlight\ looks\ //`;
if [ "$status" = "on" ] ; then
echo "Light off" | logger -t $MYNAME
$RADEONTOOL light off
exit 0
elif [ "$status" = "off" ] ; then
echo "Light on" | logger -t $MYNAME
$RADEONTOOL light on
exit 0
fi
}
TYPE=$1
set $3 # powersaved gives us "other '<content of /proc/acpi/event>'" so we must split it.
EVENT=$1 # "ibm/hotkey"
ACPI=$2 # "HKEY"
WHAT=$3 # "00000080"
SERIAL=$4 # "0000100*" *=3,4,5,7,12
# it is easier to deal with numerical values (for me :-)
declare -i VAL
VAL=0x$SERIAL # hex -> decimal
echo "VAL: '$VAL'"| \
logger -t $MYNAME
if [ "$EVENT" != "ibm/hotkey" ]; then
echo "non-hotkey-event: $TYPE $EVENT $ACPI $WHAT $SERIAL" | logger -t $MYNAME
exit 0
fi
if [ $VAL -eq 4099 ]; then
toggle_light
elif [ $VAL -eq 4100 ]; then
echo "Suspend to RAM" | logger -t $MYNAME
echo 3 > /proc/acpi/sleep
exit 0
elif [ $VAL -eq 4101 ]; then
toggle_bluetooth
elif [ $VAL -eq 4103 ]; then
toggle_wlan
elif [ $VAL -eq 4108 ]; then
echo "Suspend to disk" | logger -t $MYNAME
echo 4 > /proc/acpi/sleep
exit 0
else
DEBUG "undefined hotkey: $VAL $TYPE $EVENT $ACPI $WHAT $SERIAL" DIAG
ret=1
fi
exit $ret
--Boundary-00=_0aG1BMu312I8MD0--