suse & im-acpi

Solaris, RedHat, FreeBSD and the like
Post Reply
Message
Author
magneto
Posts: 24
Joined: Fri Sep 23, 2005 7:33 am
Location: Toulouse, France

suse & im-acpi

#1 Post by magneto » Thu Oct 13, 2005 12:31 pm

I try to use ibm_acpi on suse 9.3. After a little search, I endend up with a script ibm-acpi.sh to execute actions according to acpi events. I copied this script to the folder /usr/lib/powersave/scripts and wrote ibm-acpi.sh to the POWERSAVE_EVENT_OTHER field in /etc/sysconfig with yast2.

So the problem is that the acpi events are sent to this script but I find this error in /var/log/messages : [powersave][17426]: ERROR in Function execute_program; line 172: Came back from subprocess when trying to execute /usr/lib/powersave/scripts/ibm_acpi.sh for event other; Error: Exec format error

my script is :


#!/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/sbin/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

Eitherway if I wirte only one line to this file instead of all this stuff it gives the same error...

any help??

Post Reply
  • Similar Topics
    Replies
    Views
    Last post

Return to “Linux Questions”

Who is online

Users browsing this forum: No registered users and 1 guest