# HG changeset patch # User Dominique Corbex # Date 1224792444 0 # Node ID b19e50dd80d8150bb7dcacf35a43c7454351e763 # Parent 3a574003f9dd9a3b3e6b1e410312a5883297a8df acpid: add power savings scripts diff -r 3a574003f9dd -r b19e50dd80d8 acpid/acpi_fakekey Binary file acpid/acpi_fakekey has changed diff -r 3a574003f9dd -r b19e50dd80d8 acpid/acpi_fakekey.c --- a/acpid/acpi_fakekey.c Thu Oct 23 20:13:41 2008 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,64 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#define TestBit(bit, array) (array[(bit) / 8] & (1 << ((bit) % 8))) - -int find_keyboard() { - int i, j; - int fd; - char filename[32]; - char key_bitmask[(KEY_MAX + 7) / 8]; - - for (i=0; i<32; i++) { - snprintf(filename,sizeof(filename), "/dev/input/event%d", i); - - fd = open(filename, O_RDWR); - ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(key_bitmask)), key_bitmask); - - for (j = 0; j < BTN_MISC; j++) { - if (TestBit(j, key_bitmask)) - break; - } - - if (j < BTN_MISC) { - return fd; - } - close (fd); - } - return 0; -} - -int main(int argc, char** argv) { - int fd; - int key; - struct input_event event; - - if (argc == 2) { - key = atoi(argv[1]); - } else { - return 1; - } - - fd = find_keyboard(); - - if (!fd) { - return 2; - } - - event.type = EV_KEY; - event.code = key; - event.value = 1; - write(fd, &event, sizeof event); - - event.type = EV_KEY; - event.code = key; - event.value = 0; - write(fd, &event, sizeof event); - - return 0; -} - diff -r 3a574003f9dd -r b19e50dd80d8 acpid/key-constants --- a/acpid/key-constants Thu Oct 23 20:13:41 2008 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,246 +0,0 @@ -# Generated from $INPUT dated mar aoû 26 22:06:20 CEST 2008 -KEY_RESERVED=0 -KEY_ESC=1 -KEY_1=2 -KEY_2=3 -KEY_3=4 -KEY_4=5 -KEY_5=6 -KEY_6=7 -KEY_7=8 -KEY_8=9 -KEY_9=10 -KEY_0=11 -KEY_MINUS=12 -KEY_EQUAL=13 -KEY_BACKSPACE=14 -KEY_TAB=15 -KEY_Q=16 -KEY_W=17 -KEY_E=18 -KEY_R=19 -KEY_T=20 -KEY_Y=21 -KEY_U=22 -KEY_I=23 -KEY_O=24 -KEY_P=25 -KEY_LEFTBRACE=26 -KEY_RIGHTBRACE=27 -KEY_ENTER=28 -KEY_LEFTCTRL=29 -KEY_A=30 -KEY_S=31 -KEY_D=32 -KEY_F=33 -KEY_G=34 -KEY_H=35 -KEY_J=36 -KEY_K=37 -KEY_L=38 -KEY_SEMICOLON=39 -KEY_APOSTROPHE=40 -KEY_GRAVE=41 -KEY_LEFTSHIFT=42 -KEY_BACKSLASH=43 -KEY_Z=44 -KEY_X=45 -KEY_C=46 -KEY_V=47 -KEY_B=48 -KEY_N=49 -KEY_M=50 -KEY_COMMA=51 -KEY_DOT=52 -KEY_SLASH=53 -KEY_RIGHTSHIFT=54 -KEY_KPASTERISK=55 -KEY_LEFTALT=56 -KEY_SPACE=57 -KEY_CAPSLOCK=58 -KEY_F1=59 -KEY_F2=60 -KEY_F3=61 -KEY_F4=62 -KEY_F5=63 -KEY_F6=64 -KEY_F7=65 -KEY_F8=66 -KEY_F9=67 -KEY_F10=68 -KEY_NUMLOCK=69 -KEY_SCROLLLOCK=70 -KEY_KP7=71 -KEY_KP8=72 -KEY_KP9=73 -KEY_KPMINUS=74 -KEY_KP4=75 -KEY_KP5=76 -KEY_KP6=77 -KEY_KPPLUS=78 -KEY_KP1=79 -KEY_KP2=80 -KEY_KP3=81 -KEY_KP0=82 -KEY_KPDOT=83 -KEY_ZENKAKUHANKAKU=85 -KEY_102ND=86 -KEY_F11=87 -KEY_F12=88 -KEY_RO=89 -KEY_KATAKANA=90 -KEY_HIRAGANA=91 -KEY_HENKAN=92 -KEY_KATAKANAHIRAGANA=93 -KEY_MUHENKAN=94 -KEY_KPJPCOMMA=95 -KEY_KPENTER=96 -KEY_RIGHTCTRL=97 -KEY_KPSLASH=98 -KEY_SYSRQ=99 -KEY_RIGHTALT=100 -KEY_LINEFEED=101 -KEY_HOME=102 -KEY_UP=103 -KEY_PAGEUP=104 -KEY_LEFT=105 -KEY_RIGHT=106 -KEY_END=107 -KEY_DOWN=108 -KEY_PAGEDOWN=109 -KEY_INSERT=110 -KEY_DELETE=111 -KEY_MACRO=112 -KEY_MUTE=113 -KEY_VOLUMEDOWN=114 -KEY_VOLUMEUP=115 -KEY_POWER=116 -KEY_KPEQUAL=117 -KEY_KPPLUSMINUS=118 -KEY_PAUSE=119 -KEY_KPCOMMA=121 -KEY_HANGEUL=122 -KEY_HANJA=123 -KEY_YEN=124 -KEY_LEFTMETA=125 -KEY_RIGHTMETA=126 -KEY_COMPOSE=127 -KEY_STOP=128 -KEY_AGAIN=129 -KEY_PROPS=130 -KEY_UNDO=131 -KEY_FRONT=132 -KEY_COPY=133 -KEY_OPEN=134 -KEY_PASTE=135 -KEY_FIND=136 -KEY_CUT=137 -KEY_HELP=138 -KEY_MENU=139 -KEY_CALC=140 -KEY_SETUP=141 -KEY_SLEEP=142 -KEY_WAKEUP=143 -KEY_FILE=144 -KEY_SENDFILE=145 -KEY_DELETEFILE=146 -KEY_XFER=147 -KEY_PROG1=148 -KEY_PROG2=149 -KEY_WWW=150 -KEY_MSDOS=151 -KEY_COFFEE=152 -KEY_DIRECTION=153 -KEY_CYCLEWINDOWS=154 -KEY_MAIL=155 -KEY_BOOKMARKS=156 -KEY_COMPUTER=157 -KEY_BACK=158 -KEY_FORWARD=159 -KEY_CLOSECD=160 -KEY_EJECTCD=161 -KEY_EJECTCLOSECD=162 -KEY_NEXTSONG=163 -KEY_PLAYPAUSE=164 -KEY_PREVIOUSSONG=165 -KEY_STOPCD=166 -KEY_RECORD=167 -KEY_REWIND=168 -KEY_PHONE=169 -KEY_ISO=170 -KEY_CONFIG=171 -KEY_HOMEPAGE=172 -KEY_REFRESH=173 -KEY_EXIT=174 -KEY_MOVE=175 -KEY_EDIT=176 -KEY_SCROLLUP=177 -KEY_SCROLLDOWN=178 -KEY_KPLEFTPAREN=179 -KEY_KPRIGHTPAREN=180 -KEY_NEW=181 -KEY_REDO=182 -KEY_F13=183 -KEY_F14=184 -KEY_F15=185 -KEY_F16=186 -KEY_F17=187 -KEY_F18=188 -KEY_F19=189 -KEY_F20=190 -KEY_F21=191 -KEY_F22=192 -KEY_F23=193 -KEY_F24=194 -KEY_PLAYCD=200 -KEY_PAUSECD=201 -KEY_PROG3=202 -KEY_PROG4=203 -KEY_SUSPEND=205 -KEY_CLOSE=206 -KEY_PLAY=207 -KEY_FASTFORWARD=208 -KEY_BASSBOOST=209 -KEY_PRINT=210 -KEY_HP=211 -KEY_CAMERA=212 -KEY_SOUND=213 -KEY_QUESTION=214 -KEY_EMAIL=215 -KEY_CHAT=216 -KEY_SEARCH=217 -KEY_CONNECT=218 -KEY_FINANCE=219 -KEY_SPORT=220 -KEY_SHOP=221 -KEY_ALTERASE=222 -KEY_CANCEL=223 -KEY_BRIGHTNESSDOWN=224 -KEY_BRIGHTNESSUP=225 -KEY_MEDIA=226 -KEY_SWITCHVIDEOMODE=227 -KEY_KBDILLUMTOGGLE=228 -KEY_KBDILLUMDOWN=229 -KEY_KBDILLUMUP=230 -KEY_SEND=231 -KEY_REPLY=232 -KEY_FORWARDMAIL=233 -KEY_SAVE=234 -KEY_DOCUMENTS=235 -KEY_BATTERY=236 -KEY_BLUETOOTH=237 -KEY_WLAN=238 -KEY_UWB=239 -KEY_UNKNOWN=240 -KEY_VIDEO_NEXT=241 -KEY_VIDEO_PREV=242 -KEY_BRIGHTNESS_CYCLE=243 -KEY_BRIGHTNESS_ZERO=244 -KEY_DISPLAY_OFF=245 -KEY_WIMAX=246 -KEY_LOCK=$KEY_COFFEE -KEY_LIGHT=$KEY_F19 -KEY_VIDEOOUT=$KEY_F20 -KEY_ROTATESCREEN=$KEY_F21 -KEY_VIDEOMODECYCLE=$KEY_F22 -KEY_PRESENTATION=\KEY_F23 diff -r 3a574003f9dd -r b19e50dd80d8 acpid/receipt --- a/acpid/receipt Thu Oct 23 20:13:41 2008 +0200 +++ b/acpid/receipt Thu Oct 23 20:07:24 2008 +0000 @@ -2,10 +2,12 @@ PACKAGE="acpid" VERSION="1.0.6" +EXTRAVERSION="-3" CATEGORY="system-tools" SHORT_DESC="The ACPI event daemon" MAINTAINER="domcox@users.sourceforge.net" DEPENDS="" +BUILD_DEPENDS="linux-headers" TARBALL="$PACKAGE-$VERSION.tar.gz" WEB_SITE="http://acpid.sourceforge.net/" WGET_URL="$SF_MIRROR/$PACKAGE/$TARBALL" @@ -47,8 +49,6 @@ mkdir -p $fs/etc cp -a stuff/init.d $fs/etc/ cp -a stuff/acpi $fs/etc/ - mkdir -p $fs/var/log/ - touch $fs/var/log/acpid.log && chmod 700 $fs/var/log/acpid.log # acpi_fakekey cp -a acpi_fakekey $fs/usr/bin cp -a $KEY_FILE $fs/etc/acpi/ diff -r 3a574003f9dd -r b19e50dd80d8 acpid/stuff/acpi/ac.sh --- a/acpid/stuff/acpi/ac.sh Thu Oct 23 20:13:41 2008 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -#!/bin/sh -## -## ac.sh -## -## Made by Dominique Corbex -## Login -## -## Started on Mon Oct 6 12:56:58 2008 Dominique Corbex -## Last update -## - -# Disable laptop mode -# When laptop mode is enabled, the kernel will try to be smart -# about when to do IO, to give the disk and the SATA links as -# much time as possible in a low power state. - -if [ -e /proc/sys/vm/laptop_mode ] ; then - echo "Disabling laptop mode" - echo 0 > /proc/sys/vm/laptop_mode -fi - -# AC97 audio power saving mode -# The AC97 onboard audio chips support power saving, where the -# analog parts (codec) are powered down when no program is using -# the audio device. - -if [ -e /sys/module/snd_ac97_codec/parameters/power_save ] ; then - echo "Enabling AC97 audio power saving mode" - echo 0 > /sys/module/snd_ac97_codec/parameters/power_save -fi - -# The VM writeback time -# The VM subsystem caching allows the kernel to group consecutive -# writes into one big write, and to generally optimize the disk IO -# to be the most efficient. - -if [ -e /proc/sys/vm/dirty_writeback_centisecs ] ; then - echo "Writeback time reset back to 500ms" - echo 500 > /proc/sys/vm/dirty_writeback_centisecs -fi diff -r 3a574003f9dd -r b19e50dd80d8 acpid/stuff/acpi/battery.sh --- a/acpid/stuff/acpi/battery.sh Thu Oct 23 20:13:41 2008 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -#!/bin/sh -## -## battery.sh -## -## Made by Dominique Corbex -## Login &2 - echo "patch or install a newer kernel." >&2 -else - echo "Enabling laptop mode" - echo 5 > /proc/sys/vm/laptop_mode -fi - -# AC97 audio power saving mode -# The AC97 onboard audio chips support power saving, where the -# analog parts (codec) are powered down when no program is using -# the audio device. - -if [ -e /sys/module/snd_ac97_codec/parameters/power_save ] ; then - echo "Enabling AC97 audio power saving mode" - echo 1 > /sys/module/snd_ac97_codec/parameters/power_save - echo 1 > /dev/dsp -fi - -# The VM writeback time -# The VM subsystem caching allows the kernel to group consecutive -# writes into one big write, and to generally optimize the disk IO -# to be the most efficient. - -if [ -e /proc/sys/vm/dirty_writeback_centisecs ] ; then - echo "Writeback time set to 1500ms" - echo 1500 > /proc/sys/vm/dirty_writeback_centisecs -fi - diff -r 3a574003f9dd -r b19e50dd80d8 acpid/stuff/acpi/button.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/acpid/stuff/acpi/button.sh Thu Oct 23 20:07:24 2008 +0000 @@ -0,0 +1,39 @@ +#!/bin/sh +# button.sh - Managing button events for SliTaz +# + +source /etc/acpi/key-constants + +# logger "button.sh: event=$1" + +# take care about the way events are reported + +EVENT_TYPE=`echo $1 | cut -d/ -f1` +if [ $EVENT_TYPE = $1 ]; then + EVENT=$2 +else + EVENT=`echo "$1" | cut -d/ -f2` +fi + +case $EVENT in + power) + logger "Event: button/power - sending KEY_EXIT($KEY_EXIT)" + /usr/bin/acpi_fakekey $KEY_EXIT + ;; + lid) + if [ -e /usr/bin/suspend ] ; then + logger "Event: button/lid - suspending" + /usr/bin/suspend + else + logger "Event: button/lid - /usr/bin/suspend not found, skipping.." + fi + ;; + sleep) + if [ -e /usr/bin/hibernate ] ; then + logger "Event: button/sleep - hibernating" + /usr/bin/hibernate + else + logger "Event: button/sleep - /usr/bin/hibernate not found, skipping.." + fi + ;; +esac diff -r 3a574003f9dd -r b19e50dd80d8 acpid/stuff/acpi/events/ac --- a/acpid/stuff/acpi/events/ac Thu Oct 23 20:13:41 2008 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -# /etc/acpi/event/ac -# called when the user connects ac power - -event=ac_adapter -action=/etc/acpi/ac.sh diff -r 3a574003f9dd -r b19e50dd80d8 acpid/stuff/acpi/events/ac.conf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/acpid/stuff/acpi/events/ac.conf Thu Oct 23 20:07:24 2008 +0000 @@ -0,0 +1,6 @@ +# /etc/acpi/event/ac.conf +# ac power events + +event=ac_adapter +action=/etc/acpi/power-supply.sh + diff -r 3a574003f9dd -r b19e50dd80d8 acpid/stuff/acpi/events/battery --- a/acpid/stuff/acpi/events/battery Thu Oct 23 20:13:41 2008 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -# /etc/acpi/event/battery -# called when ac power goes away - -event=battery -action=/etc/acpi/battery.sh diff -r 3a574003f9dd -r b19e50dd80d8 acpid/stuff/acpi/events/battery.conf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/acpid/stuff/acpi/events/battery.conf Thu Oct 23 20:07:24 2008 +0000 @@ -0,0 +1,6 @@ +# /etc/acpi/event/battery.conf +# Battery events + +event=battery +action=/etc/acpi/power-supply.sh + diff -r 3a574003f9dd -r b19e50dd80d8 acpid/stuff/acpi/events/button.conf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/acpid/stuff/acpi/events/button.conf Thu Oct 23 20:07:24 2008 +0000 @@ -0,0 +1,6 @@ +# /etc/acpi/event/button +# lid, sleep or power button events + +event=button +action=/etc/acpi/button.sh %e + diff -r 3a574003f9dd -r b19e50dd80d8 acpid/stuff/acpi/power-supply.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/acpid/stuff/acpi/power-supply.sh Thu Oct 23 20:07:24 2008 +0000 @@ -0,0 +1,235 @@ +#!/bin/sh +# /etc/acpi/power-supply.sh - Managing power events for SliTaz +# For Tips & Tricks see http://www.lesswatts.org + +# This script turns off power savings mode on ac or when the +# battery almost runs out in a attempt to limit data loss in +# a case of power failure. + +ENABLED=1 +DISABLED=0 + +# AC status (from /sys/class/power_supply/online) +ON_LINE=1 +OFF_LINE=0 + +# Battery status +LOW_BAT=0 +HIGH_BAT=1 + +# Determining the power state. + +ac_status() +{ + POWER_SUPPLY_MAINS=$DISABLED + AC_STATUS=$OFF_LINE + for POWER_SUPPLY in /sys/class/power_supply/* ; do + if [ -f $POWER_SUPPLY/type ] ; then + if [ "$(cat $POWER_SUPPLY/type)" = "Mains" ] ;then + echo -n "Determining power state from $POWER_SUPPLY: " + POWER_SUPPLY_MAINS=$ENABLED + if [ "$(cat $POWER_SUPPLY/online)" = 1 ] ; then + AC_STATUS=$ON_LINE + echo "on-line" + else + echo "off-line" + fi + fi + fi + done + if [ $POWER_SUPPLY_MAINS -eq $DISABLED ] ; then + $AC_STATUS=$ON_LINE + fi +} + +# Determining the battery state. + +battery_status() +{ + BATTERY_STATUS=$LOW_BAT + for BATT in /sys/class/power_supply/* ; do + BATT_TYPE=$(cat $BATT/type) + echo "$BATT is of type $BATT_TYPE." + if [ "$BATT_TYPE" = "Battery" ] ; then + echo " Checking levels for $BATT." + # Only do if the battery is present + if [ $(cat $BATT/present) -eq 1 ] ; then + + # Get the remaining capacity. + if [ -f $BATT/charge_now ] ; then + REMAINING=$(cat $BATT/charge_now) + elif [ -f $BATT/energy_now ] ; then + REMAINING=$(cat $BATT/energy_now) + else + REMAINING=0 + fi + if [ -z "$REMAINING" -o "$REMAINING" -eq 0 ] ; then + echo " Battery does not report remaining charge. Perhaps it is not present?" + else + echo " Remaining charge: $REMAINING" + + # Get the alarm level + ALARM_LEVEL=$(cat $BATT/alarm) + if [ "$ALARM_LEVEL" -eq 0 ] ; then + + # Get the full capacity. + + if [ -f $BATT/charge_full_design ] ; then + CAPACITY=$(cat $BATT/charge_full_design) + elif [ -f $BATT/energy_full_design ] ; then + CAPACITY=$(cat $BATT/energy_full_design) + else + CAPACITY=0 + fi + if [ -z "$CAPACITY" -o "$CAPACITY" -eq 0 ] ; then + echo " Battery does not report design full charge, using non-design full charge." + + if [ -f $BATT/charge_full ] ; then + CAPACITY=$(cat $BATT/charge_full) + elif [ -f $BATT/energy_full_design ] ; then + CAPACITY=$(cat $BATT/energy_full) + else + CAPACITY=0 + fi + if [ -z "$CAPACITY" -o "$CAPACITY" -eq 0] ; then + echo " Battery does not report non-design full charge." + fi + fi + echo " Full capacity: $CAPACITY" + ALARM_LEVEL=$((CAPACITY*5/100)) + fi + echo " Alarm level: $ALARM_LEVEL" + if [ "$ALARM_LEVEL" -ne 0 ] ; then + if [ "$REMAINING" -ge "$ALARM_LEVEL" ] ; then + # this battery does count as having enough charge. + BATTERY_STATUS=$HIGH_BAT + echo " Battery status: high" + else + echo " Battery status: low" + fi + fi + fi + else + echo "Battery is not present." + fi + fi + done +} + +online_mode() +{ + # Disable laptop mode + # When laptop mode is enabled, the kernel will try to be smart + # about when to do IO, to give the disk and the SATA links as + # much time as possible in a low power state. + + if [ -e /proc/sys/vm/laptop_mode ] ; then + echo "Disabling laptop mode" + echo 0 > /proc/sys/vm/laptop_mode + fi + + # AC97 audio power saving mode + # The AC97 onboard audio chips support power saving, where the + # analog parts (codec) are powered down when no program is using + # the audio device. + + if [ -e /sys/module/snd_ac97_codec/parameters/power_save ] ; then + echo "Disabling AC97 audio power saving mode" + echo 0 > /sys/module/snd_ac97_codec/parameters/power_save + fi + + # The VM writeback time + # The VM subsystem caching allows the kernel to group consecutive + # writes into one big write, and to generally optimize the disk IO + # to be the most efficient. + + if [ -e /proc/sys/vm/dirty_writeback_centisecs ] ; then + echo "Writeback time reset to 500ms" + echo 500 > /proc/sys/vm/dirty_writeback_centisecs + fi +} + +offline_mode() +{ + # Enable laptop mode + # When laptop mode is enabled, the kernel will try to be smart + # about when to do IO, to give the disk and the SATA links as + # much time as possible in a low power state. + + if [ ! -e /proc/sys/vm/laptop_mode ] ; then + echo "Kernel does not have support for laptop mode." + else + echo "Enabling laptop mode" + echo 5 > /proc/sys/vm/laptop_mode + fi + + # AC97 audio power saving mode + # The AC97 onboard audio chips support power saving, where the + # analog parts (codec) are powered down when no program is using + # the audio device. + + if [ -e /sys/module/snd_ac97_codec/parameters/power_save ] ; then + echo "Enabling AC97 audio power saving mode" + echo 1 > /sys/module/snd_ac97_codec/parameters/power_save + echo 1 > /dev/dsp + fi + + # The VM writeback time + # The VM subsystem caching allows the kernel to group consecutive + # writes into one big write, and to generally optimize the disk IO + # to be the most efficient. + + if [ -e /proc/sys/vm/dirty_writeback_centisecs ] ; then + echo "Writeback time set to 1500ms" + echo 1500 > /proc/sys/vm/dirty_writeback_centisecs + fi +} + +power_status() +{ + if [ $(cat /proc/sys/vm/dirty_writeback_centisecs) -gt 1000 ]; then + POWER_SAVINGS=$ENABLED + echo "power-savings-mode enabled" + else + POWER_SAVINGS=$DISABLED + echo "power-savings-mode disabled" + fi +} + +custom_scripts() +{ + # Custom scripts in /etc/acpi/ac.d + + if [ -d /etc/acpi/ac.d ]; then + for SCRIPT in /etc/acpi/ac.d/*.sh; do + . $SCRIPT $AC_STATUS $BATTERY_STATUS $0 + done + fi + + # Custom scripts in /etc/acpi/battery.d + + if [ -d /etc/acpi/battery.d ]; then + for SCRIPT in /etc/acpi/battery.d/*.sh; do + . $SCRIPT $AC_STATUS $BATTERY_STATUS $0 + done + fi +} + +ac_status +battery_status +power_status +case "$AC_STATUS+$BATTERY_STATUS" in + "$OFF_LINE+$HIGH_BAT") + if [ $POWER_SAVINGS = $DISABLED ]; then + logger "Start power savings mode" + offline_mode + fi + ;; + *) + if [ $POWER_SAVINGS = $ENABLED ]; then + logger "Stop power savings mode" + online_mode + fi + ;; +esac +custom_scripts \ No newline at end of file diff -r 3a574003f9dd -r b19e50dd80d8 acpid/stuff/init.d/acpid --- a/acpid/stuff/init.d/acpid Thu Oct 23 20:13:41 2008 +0200 +++ b/acpid/stuff/init.d/acpid Thu Oct 23 20:07:24 2008 +0000 @@ -12,11 +12,12 @@ DESC="ACPI event deamon" DAEMON=/usr/sbin/acpid OPTIONS=$ACPID_OPTIONS -PIDFILE=/var/run/acpid.pid +NPID=`ps ax | grep $DAEMON | wc -l` +PID=`ps ax | grep $DAEMON | awk '{print $1}'` case "$1" in start) - if [ -f $PIDFILE ] ; then + if [ $NPID -ne 0 ] ; then echo "$NAME already running." exit 1 fi @@ -25,21 +26,21 @@ status ;; stop) - if [ ! -f $PIDFILE ] ; then + if [ $NPID -eq 0 ] ; then echo "$NAME is not running." exit 1 fi echo -n "Stopping $DESC: $NAME... " - kill `cat $PIDFILE` + kill $PID status ;; restart) - if [ ! -f $PIDFILE ] ; then + if [ $NPID -eq 0 ] ; then echo "$NAME is not running." exit 1 fi echo -n "Restarting $DESC: $NAME... " - kill `cat $PIDFILE` + kill $PID sleep 2 $DAEMON $OPTIONS > /dev/null status