View previous topic :: View next topic |
Author |
Message |
friday n00b
Joined: 07 Feb 2003 Posts: 28 Location: Germany
|
Posted: Tue Sep 02, 2003 2:13 am Post subject: [SCRIPT]s to handle ACPI events (incl. laptop-mode) |
|
|
scripts to handle ACPI events
Here are is my config for an HP Compaq nx9000 Laptop.
It is inspired by https://forums.gentoo.org/viewtopic.php?t=63362
Thank you guys for all your great postings!
Features:
- needs only one file in /etc/acpi/events
- everthing else is done through /etc/acpi/action.sh
- handles battery low, ac in/out, powerbutton, lid close, laptop-mode
- /etc/acpi/on_boot.sh checks for an AC adapter at boot and takes action depending on that. It should be called through /etc/conf.d/local.start
What you need:
- Laptop with ACPI
- Kernel with ACPI + laptop-mode
- X must accept connections from localhost (xhost +localhost)
- for speedstepping the cpu I recommend powernowd, which can be found at http://www.deater.net/john/powernowd.html
- maybe some time to tweak it to your needs and post your experience
TODO:
- integrate your improvements
Latest versions available from http://cknoerle.homelinux.org/nx9000/stuff/acpi/
Also check my page about Gentoo on the HP Compaq nx9000 Laptop: http://cknoerle.homelinux.org/nx9000/
/etc/acpi/events/all_events
Code: |
# This file matches all acpi events so there is no need for more
# event files in /etc/acpi/events/
# It calls /etc/acpi/action.sh with the whole event as arguments.
# The event is matched through an regular expression.
event=.*
action=/etc/acpi/action.sh %e
|
/etc/acpi/action.sh
Code: |
#!/bin/bash
#
# /etc/acpi/action.sh (2004.01.17)
# called by acpid for all events
# Christopher Knoerle <cknoerle@gmx.net>
#
# This works with gentoo-sources, ac-sources, mm-sources on my
# HP Compaq nx9000 Laptop. For more information have a look at
# http://cknoerle.homelinux.org/nx9000/
# The latest version is available from
# http://cknoerle.homelinux.org/nx9000/stuff/acpi/
# This should be placed in /etc/acpi/action.sh and should be called by acpid.
# To make this happen you need the acpid installed and running.
# acpid can be obtained from http://acpid.sourceforge.net
# For this to work you need only one event handler in /etc/acpi/event
# It should contain something like the following:
#
# event=.*
# action=/etc/acpi/action.sh %e
# For speedstepping the cpu I use powernowd, which can be obtained from
# http://www.deater.net/john/powernowd.html
# I have written a very basic initscript for Gentoo, which you can find at
# http://cknoerle.homelinux.org/nx9000/stuff/
#
# For even better saving of battery power use a kernel with laptop-mode
# (see http://kerneltrap.org/node/view/653) and the laptop-mode shell-script
# which you can find at http://cknoerle.homelinux.org/nx9000/stuff/
# let's set some paths
LOGGER="/usr/bin/logger -t ACPID" # logs to syslog - an echo logs to /var/log/acpid
XGAMMA="/usr/X11R6/bin/xgamma"
XSET="/usr/X11R6/bin/xset"
LAPTOPMODE="/sbin/laptop-mode"
HDPARM="/sbin/hdparm"
#CPU_LIMIT="/proc/acpi/processor/CPU0/limit" # not needed with powernowd
BAT_STATE="/proc/acpi/battery/BAT1/state"
BAT_INFO="/proc/acpi/battery/BAT1/info"
AC_STATE="/proc/acpi/ac_adapter/ACAD/state"
LID_STATE="/proc/acpi/button/lid/LID/state"
# if we didn't know about an event
# log to /var/log/acpid to do something like 'grep #### /var/log/acpid' :-)
no_action ()
{
echo "#### NO ACTION FOR EVENT: " $*
exit 1
}
# AC Adapter plugged in
acad_in ()
{
$LOGGER "AC Adapter plugged IN"
if ps -A | grep -q X
then
$XGAMMA -d 0:0 -gamma 1.0 # set gamma in X to 100%
$XSET -d 0:0 dpms 0 0 600 # shutdown display after 600s
fi
$LAPTOPMODE stop # stop laptop-mode
$HDPARM -S 240 /dev/hda > /dev/null 2>&1 # spindown after 20min
$HDPARM -B 255 /dev/hda > /dev/null 2>&1 # disable drive's APM
# not needed with kernel 2.6.x - use powernowd
#echo -n 0:0 > $CPU_LIMIT # set cpu performance state 0, throttling to 0
}
# AC Adapter plugged out
acad_out ()
{
$LOGGER "AC Adapter plugged OUT"
if ps -A | grep -q X
then
$XGAMMA -d 0:0 -gamma 0.7 # set gamma in X to 70%
$XSET -d 0:0 dpms 0 0 120 # shutdown display after 120s
fi
$LAPTOPMODE start # start laptop-mode
$HDPARM -S 4 /dev/hda > /dev/null 2>&1 # spindown after 20s
$HDPARM -B 1 /dev/hda > /dev/null 2>&1 # enable drives's APM
# not needed with kernel 2.6.x - use powernowd
#echo -n 1:0 > $CPU_LIMIT # set cpu performance state 1, throttling to 0
}
# state of battery changed
# shutdown if battery capacity is low
battery ()
{
if grep -q discharging $BAT_STATE
then
BAT_REMAIN=`awk '/remaining/ { print $3 }' $BAT_STATE`
if (($BAT_REMAIN < `awk '/warning/ { print $4 }' $BAT_INFO`))
then
$LOGGER "battery capacity is critically low"
btn_pwr
fi
fi
}
# powerbutton pressed
# if kde is running try to show dialog - else shutdown immediately
btn_pwr ()
{
$LOGGER "Powerbutton pressed"
if test -f $KDEDIR/bin/dcop && $KDEDIR/bin/dcop kdesktop > /dev/null 2>&1
then
$LOGGER "KDE running: asking user what to do"
dcop --all-sessions ksmserver ksmserver logout 1 2 0 && exit 0
else
$LOGGER "shutdown initiated"
/sbin/init 0
fi
}
# lid closed/opened
# Anything useful to do when lid is closed/opened?
btn_lid ()
{
if grep -q open $LID_STATE
then
$LOGGER "Lid opened"
else
$LOGGER "Lid closed"
fi
}
# let's see which event occured and what action to take :-)
# have a look at /var/log/acpid to see what your events look like
# and adjust accordingly
case "$*" in
ac_adapter\ ACAD\ 00000080\ 00000000)
acad_out
;;
ac_adapter\ ACAD\ 00000080\ 00000001)
acad_in
;;
battery\ BAT1\ 00000080\ 00000001)
battery
;;
button?lid\ LID\ 00000080\ ????????)
# the last eight digits count the times the lid was shut
btn_lid
;;
button?power\ PWRF\ 00000080\ ????????)
# the last eight digits count the times the button was pressed
btn_pwr
;;
*)
no_action
;;
esac
# EOF
|
/etc/acpi/on_boot.sh
Code: |
#!/bin/bash
#
# /etc/acpi/on_boot.sh (2004.01.17)
# called on boot to check for AC Adapter
# Christopher Knoerle <cknoerle@gmx.net>
#
# This works with gentoo-sources, ac-sources, mm-sources on my
# HP Compaq nx9000 Laptop. For more information have a look at
# http://cknoerle.homelinux.org/nx9000/
# The latest version is available from
# http://cknoerle.homelinux.org/nx9000/stuff/acpi/
# This should be placed in /etc/acpi/on_boot.sh and should be called
# through /etc/conf.d/local.start
# You can achieve this by doing the following:
# echo "/etc/acpi/on_boot.sh" >> /etc/conf.d/local.start
# lets set some paths
LOGGER="/usr/bin/logger -t ACPID" # logs to syslog - an echo logs to /var/log/acpid
XGAMMA="/usr/X11R6/bin/xgamma"
XSET="/usr/X11R6/bin/xset"
LAPTOPMODE="/sbin/laptopmode"
HDPARM="/sbin/hdparm"
#test for ac
if grep -q 'off-line' /proc/acpi/ac_adapter/ACAD/state
then
$LOGGER "AC Adapter plugged OUT"
if ps -A | grep -q X
then
$XGAMMA -d 0:0 -gamma 0.7 # set gamma in X to 70%
$XSET -d 0:0 dpms 0 0 120 # shutdown display after 120s
fi
$LAPTOPMODE start # start laptop-mode
$HDPARM -S 4 /dev/hda > /dev/null 2>&1 # spindown after 20s
$HDPARM -B 1 /dev/hda > /dev/null 2>&1 # enable drives's APM
# not needed anymore - use powernowd
#echo -n 1:0 > /proc/acpi/processor/CPU0/limit # set cpu performance state 1, throttling to 0
else
exit 0
fi
# EOF
|
Last edited by friday on Sat Jan 31, 2004 10:43 pm; edited 21 times in total |
|
Back to top |
|
|
puddpunk l33t
Joined: 20 Jul 2002 Posts: 681 Location: New Zealand
|
Posted: Tue Sep 02, 2003 12:45 pm Post subject: |
|
|
hey man! Thats great! I've been looking for a set of scripts like that for my laptop
Thanks heaps for sharing that mate.
Cheers,
Chris. |
|
Back to top |
|
|
friday n00b
Joined: 07 Feb 2003 Posts: 28 Location: Germany
|
Posted: Tue Sep 02, 2003 12:54 pm Post subject: |
|
|
Please post any changes needed for your laptop and/or additions you made
Also don't forget your laptop model.
Happy powersaving |
|
Back to top |
|
|
artooman n00b
Joined: 13 Aug 2002 Posts: 23 Location: Illinois
|
Posted: Wed Oct 08, 2003 11:54 pm Post subject: shutting down the screen on lid close |
|
|
Does anyone have any idea how to shut off the notebook screen? I would be great to update this script to shutoff the screen when the lid closes. |
|
Back to top |
|
|
friday n00b
Joined: 07 Feb 2003 Posts: 28 Location: Germany
|
Posted: Thu Oct 09, 2003 12:16 am Post subject: |
|
|
What exactly do you mean?
When I close the lid on my nx9000 the display is turned off.
Maybe the xset manpage can help you:
Quote: |
dpms flags...
The dpms option allows the DPMS (Energy Star) parameters to be set. The option can take up to three numerical values, or the `force' flag followed by a DPMS state. The `force' flags forces the server to immediately switch to the DPMS state specified. The DPMS state can be one of `standby', `suspend', `off', or `on'. When numerical values are given, they set the inactivity period (in units of seconds) before the three modes are activated. The first value given is for the `standby' mode, the second is for the `suspend' mode, and the third is for the `off' mode. Setting these values implicitly enables the DPMS features. A value of zero disables a particular mode.
|
Any ideas what else to do when the lid is closed? |
|
Back to top |
|
|
jocsch n00b
Joined: 01 Sep 2002 Posts: 36
|
Posted: Thu Oct 09, 2003 9:20 pm Post subject: radeon |
|
|
Depends on your graphic chip. I have a radeon and there is this nice tool called radeontool. Already in portage.
Do a
Code: |
radeontool light off
|
to switch the display off. |
|
Back to top |
|
|
aman Apprentice
Joined: 07 Sep 2003 Posts: 198 Location: Bay Area, California
|
Posted: Fri Oct 10, 2003 7:05 am Post subject: |
|
|
But you are not turning off the display, you are just turning off the backlight. If you look very closely in low light, you will still be able to make out your desktop. So does anybody know how to really kill the display and really save some power? _________________ Yes, I do run Gentoo on production servers... |
|
Back to top |
|
|
hulk2nd Guru
Joined: 25 Mar 2003 Posts: 512 Location: Freiburg, Germany
|
Posted: Fri Oct 10, 2003 10:34 am Post subject: |
|
|
@friday
how did you know the syntax from the acpi events? cause i have now three different scripts and in every one the syntax of the event is different. with the latest version of acpid the scripts dont work anymore so i would like to know how i can come to the syntax to get them working again.
thanks in advance and greets,
hulk |
|
Back to top |
|
|
friday n00b
Joined: 07 Feb 2003 Posts: 28 Location: Germany
|
Posted: Fri Oct 10, 2003 10:47 am Post subject: |
|
|
acpid logs the received events to /var/log/acpid (on my machine).
Take a look at the acpid manpage
HTH |
|
Back to top |
|
|
Bash[DevNull] Guru
Joined: 10 Oct 2003 Posts: 333
|
Posted: Wed Oct 15, 2003 10:27 pm Post subject: New addons |
|
|
My ACPI support not full, and i have not LID-STATUS... but by event and values that transmit acpid we can determinate OPEN/CLOSE status...
Code: | VALUE2=$4
btn_lid ()
{
if [ -e $LID_STATE ] ; then
if grep -q open $LID_STATE >/dev/null 2>&1
then
#OPEN
....
fi
else
#CLOSE
....
fi
else
if (( $(($VALUE2 % 2)) == 1))
then
#Close
....
else
#OPEN
....
fi
fi
} |
And some add-ons for battery!
It is will be notice all time from alarm mWh to low mWh (fro acpi-proc)
Code: | BAT_STATE="/proc/acpi/battery/BAT0/state"
BAT_INFO="/proc/acpi/battery/BAT0/info"
BAT_ALARM="/proc/acpi/battery/BAT0/alarm"
BAT_ALR=`awk '{ print $2}' $BAT_ALARM 2>/dev/null || echo "300"`
BAT_LOW=`awk '/low/ { print $4 }' $BAT_INFO 2>/dev/null || echo "150"`
{
if grep -q discharging $BAT_STATE >/dev/null 2>&1
then
if ((`awk '/remaining/ { print $3 }' $BAT_STATE` < $BAT_LOW))
then
$LOGGER "[acpid] battery capacity is critical low."
else
$LOGGER "[acpid] battery capacity less than $BAT_ALR mWh"
BAT_ALR=$(($BAT_ALR - 50))
echo $BAT_ALR > $BAT_ALARM
$MPL "/etc/acpi/sounds/Diving In.mp3" 2>/dev/null
fi
fi
} |
_________________ Biomechanical Artificial Sabotage Humanoid |
|
Back to top |
|
|
Bash[DevNull] Guru
Joined: 10 Oct 2003 Posts: 333
|
Posted: Thu Oct 16, 2003 4:01 am Post subject: New version |
|
|
I modifer a little previous script and now:
1) If LID closed monitor is off
2) When bat. less than alarm mWh LapTop starting to beeping !
Code: | VALUE2=$4
# if lid closed force monitor off
btn_lid ()
{
if grep -v -q open $LID_STATE >/dev/null 2>&1 || (( $(($VALUE2 % 2)) == 1))
then
$LOGGER "[acpid] lid is closed"
if ps -A | grep -q X ; then
$XSET dpms force off
fi
else
$LOGGER "[acpid] lid is opened"
if ps -A | grep -q X ; then
$XSET dpms force on
fi
fi
}
LOGGER="/usr/bin/logger"
XSET="/usr/X11R6/bin/xset -display :0.0"
BEEP="/usr/bin/beep"
BAT_STATE="/proc/acpi/battery/BAT0/state"
LID_STATE="/proc/acpi/button/lid/LID/state"
BAT_INFO="/proc/acpi/battery/BAT0/info"
BAT_ALARM="/proc/acpi/battery/BAT0/alarm"
BAT_ALR=`awk '{ print $2}' $BAT_ALARM 2>/dev/null || echo "300"`
BAT_LOW=`awk '/low/ { print $4 }' $BAT_INFO 2>/dev/null || echo "150"`
battery ()
{
if grep -q discharging $BAT_STATE >/dev/null 2>&1
then
if ((`awk '/remaining/ { print $3 }' $BAT_STATE` < $BAT_LOW))
then
$LOGGER "[acpid] battery capacity is critical low."
btn_pwr
else
$LOGGER "[acpid] battery capacity less than $BAT_ALR mWh"
echo $BAT_LOW > $BAT_ALARM
# start beep'ing with delay 5 sec
$BEEP -f 1500 -r 100 -d 5000 &
fi
fi
} |
_________________ Biomechanical Artificial Sabotage Humanoid |
|
Back to top |
|
|
hulk2nd Guru
Joined: 25 Mar 2003 Posts: 512 Location: Freiburg, Germany
|
Posted: Thu Oct 16, 2003 8:57 pm Post subject: |
|
|
thanks @friday ... should haved used my eyes ...
i have another question:
if you look at this string for example:
Code: | $XSET -d 0:0 dpms 0 0 120 |
is it possible to say the radeontool to turn off the backlight after 120s except xset, cause xset doesnt work here. in other words: how can i implement a delay into the command "radeontool light off"?
EDIT
ok, i've found a solution
there is a perl script that recognizes a running xscreensaver and then activates the radeontool. if somebody is interested (it's not my one, just found it on the web!) ...
Code: | #!/usr/bin/perl -w
use strict;
#
# This handy script watches when the screensaver activates and
# toggles the LCD backlight. You won't see more than a
# second of the screensaver, so you might as well chose one
# which consumes few MIPS/battery.
#
# You will probably want to make this script owned by root
# and SUID. Also you will need the perl-suidperl package installed
# for RedHat systems.
# chown root lightwatch
# chmod u+x lightwatch
#
$ENV{'PATH'} = '/bin:/usr/bin';
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
$<=0; # become root not just effective root
open(XS,"/usr/bin/xscreensaver-command -watch|") or die;
while(<XS>) {
if(/^BLANK/i) {
system("/usr/bin/radeontool light off");
} elsif(/^UNBLANK/i) {
system("/usr/bin/radeontool light on");
}
} | EDIT
greets,
hulk |
|
Back to top |
|
|
captnjameskirk n00b
Joined: 11 Jun 2002 Posts: 48
|
Posted: Sun Oct 19, 2003 5:59 pm Post subject: |
|
|
I've modified the lightwatch script somewhat to suit my needs. I wanted some screensaver activity before the light was turned off. Also, I removed the need for perl-suidperl (but added the need for sudo). After the screensaver has cycled the specified number of times, xcreensaver-command -throttle is used to turn off any screensaver activity at all so no cpu cycles are used, and the light is turned off.
Code: | #!/usr/bin/perl -w
# This script has been adapted to allow using sudo to
# execute radeontool, and to turn the light off after
# a specified number of screensaver cycles.
# If radeontool is in /usr/bin add /usr/bin/radeontool
# to the sudoers file so that no password is needed
# to execute the command by the user who is running
# this script. Make sure that xscreensaver is set
# to cycle between savers every couple of minutes,
# for example 2, then set $max to 10 to have the
# light turned off after 20 minutes. Then place this
# script in your .xinitrc file so that it is run after
# xscreensaver is started.
$c=0; # screensaver counter
$max=10; # max cycles before turning light off
open(XS,"xscreensaver-command -watch|") or die;
while(<XS>) {
if(/^RUN/i) {
$c++;
# after $max changes of the screensaver, turn the light off
if($c>=$max) {
system("sudo /usr/bin/radeontool light off");
# turn off running display modes to save cpu cycles
system("xscreensaver-command -throttle > /dev/null");
}
} elsif(/^UNBLANK/i) {
if($c>=$max) {
$c=0; # reset the counter
system("sudo /usr/bin/radeontool light on");
system("xscreensaver-command -unthrottle > /dev/null");
}
}
}
|
Oops, edited to correct a typo. _________________ Are you out of your Vulcan mind? |
|
Back to top |
|
|
crisscross n00b
Joined: 21 Aug 2003 Posts: 24
|
Posted: Fri Nov 07, 2003 6:01 am Post subject: |
|
|
I am having a problem tracking ACPI events to see what events are used on my Inspiron 1100 I appoligize for my lack of knowledge on this topic however this is my first time to run linux on my laptop.
I tried to run acpi in debug mode here are my results
Code: | [Thu Nov 6 23:59:33 2003] BEGIN HANDLER MESSAGES
/bin/sh: -c: line 1: syntax error near unexpected token `;;'
/bin/sh: -c: line 1: `/etc/acpi/default.sh ;;'
[Thu Nov 6 23:59:33 2003] END HANDLER MESSAGES
[Thu Nov 6 23:59:33 2003] action exited with status 2
[Thu Nov 6 23:59:33 2003] DBG: 1 total rule matched
[Thu Nov 6 23:59:33 2003] completed event " ;;"
[Thu Nov 6 23:59:33 2003] received event "esac"
[Thu Nov 6 23:59:33 2003] DBG: rule from /etc/acpi/events/default matched
[Thu Nov 6 23:59:33 2003] executing action "/etc/acpi/default.sh esac"
[Thu Nov 6 23:59:33 2003] BEGIN HANDLER MESSAGES
[Thu Nov 6 23:59:33 2003] END HANDLER MESSAGES
[Thu Nov 6 23:59:33 2003] action exited with status 0
[Thu Nov 6 23:59:33 2003] DBG: 1 total rule matched
[Thu Nov 6 23:59:33 2003] completed event "esac" |
what is it that i am looking for here?
The 3 things that I am looking for is the
a lid close event so that I can call the xset dpms force off
a power button press so that I can call the xset dpms force standby
and the 2nd button on the laptop which in xp would exicute a browser.
Any help would be great . Thanks alot. |
|
Back to top |
|
|
friday n00b
Joined: 07 Feb 2003 Posts: 28 Location: Germany
|
Posted: Fri Nov 07, 2003 6:32 am Post subject: |
|
|
Code: |
completed event " ;;"
received event "esac"
completed event "esac"
|
Looks messed up somehow...
On mx HP/Compaq nx9000 an event-log look like this:
Code: |
received event "button/lid LID 00000080 00000001"
...
completed event "button/lid LID 00000080 00000001"
received event "button/power PWRF 00000080 00000001"
...
completed event "button/power PWRF 00000080 00000001"
|
The "button/power PWRF 00000080 00000001" strings is what to match with the rules.
Maybe there is a solution on http://acpi.sourceforge.net/ |
|
Back to top |
|
|
crisscross n00b
Joined: 21 Aug 2003 Posts: 24
|
Posted: Sat Nov 08, 2003 2:37 am Post subject: |
|
|
What commands did you use to trap your events? |
|
Back to top |
|
|
friday n00b
Joined: 07 Feb 2003 Posts: 28 Location: Germany
|
Posted: Sat Nov 08, 2003 11:40 am Post subject: |
|
|
Well as mentioned before the acpid logs to /var/log/acpid by default.
There you can look up what a certain event looks like.
Then you can modify my action.sh script to match your events and place all the files in the mentioned directories.
HTH |
|
Back to top |
|
|
crisscross n00b
Joined: 21 Aug 2003 Posts: 24
|
Posted: Sat Nov 08, 2003 3:49 pm Post subject: |
|
|
My log file just reads.
Code: | [Thu Nov 6 21:15:05 2003] starting up
[Thu Nov 6 21:15:05 2003] 1 rule loaded
[Thu Nov 6 21:28:05 2003] exiting
[Thu Nov 6 21:37:11 2003] starting up
[Thu Nov 6 21:37:11 2003] 1 rule loaded
[Thu Nov 6 21:38:15 2003] exiting
[Thu Nov 6 21:38:16 2003] starting up
[Thu Nov 6 21:38:16 2003] 1 rule loaded |
If I run this command:
acpid -d -e /etc/acpi/events/default
I get these results.
Code: | [Sat Nov 8 09:50:21 2003] starting up
[Sat Nov 8 09:50:21 2003] DBG: parsing conf file /etc/acpi/events/default
[Sat Nov 8 09:50:21 2003] 1 rule loaded
[Sat Nov 8 09:50:21 2003] received event " This is the ACPID default configuration, it takes all"
[Sat Nov 8 09:50:21 2003] DBG: rule from /etc/acpi/events/default matched
[Sat Nov 8 09:50:21 2003] executing action "/etc/acpi/default.sh This is the ACPID default configuration, it takes all"
[Sat Nov 8 09:50:21 2003] BEGIN HANDLER MESSAGES
/bin/sh: line 1: /etc/acpi/default.sh: Permission denied
[Sat Nov 8 09:50:22 2003] END HANDLER MESSAGES
|
|
|
Back to top |
|
|
friday n00b
Joined: 07 Feb 2003 Posts: 28 Location: Germany
|
Posted: Sat Nov 08, 2003 4:28 pm Post subject: |
|
|
acpid -d turns on debug mode. That's ok.
acpid -e /etc/acpi/events/default is nonsense.
This is definitely _not_ the file your kernel writes the acpi events to. This should be /proc/acpi/events which is read by acpid by default. So you don't have to give the -e option unless your kernel's acpi-events-interface is not /proc/acpi/events.
All of this is explained in the manpage, of course.
So what you have to do is start the acpid by typing '/etc/init.d/acpid start'. After that the acpid "listens" for events through the file /proc/acpi/events and logs these and the taken actions to /var/log/acpid.
Try the following:
'tail -f /var/log/acpid' and then close the lid of your notebook or plug the AC-adapter in/out. You will see
The directory /etc/acpi/events/ contains files whith rules.
These are read by acpid on startup to know, what to do when a certain event is received. With my setup you can safely delete the default in there and copy my all_events and name it whatever you want.
It tells acpid what to do when an event matched by the file is received.
In my setup it would always execute /etc/acpi/action.sh and pass the whole event to it.
action.sh then tries to match the event and execute some stuff depending on that.
I'd suggest having a look at the acpid manpage and http://www.tldp.org/LDP/abs/html/
HTH |
|
Back to top |
|
|
crisscross n00b
Joined: 21 Aug 2003 Posts: 24
|
Posted: Sat Nov 08, 2003 4:38 pm Post subject: |
|
|
This is my exact problem.
tail -f /var/log/acpid
Code: | [Thu Nov 6 23:51:02 2003] 1 rule loaded
[Fri Nov 7 00:06:26 2003] exiting
[Fri Nov 7 20:54:49 2003] starting up
[Fri Nov 7 20:54:49 2003] 1 rule loaded
[Fri Nov 7 20:57:57 2003] exiting
[Fri Nov 7 21:38:12 2003] starting up
[Fri Nov 7 21:38:12 2003] 1 rule loaded
[Fri Nov 7 21:45:14 2003] exiting
[Sat Nov 8 10:37:50 2003] starting up
[Sat Nov 8 10:37:50 2003] 1 rule loaded |
i can tail it all I want i do not see the events.
I am sure that if I could find out what the actual event names where when I do somethign like close the lid or press the power button I could do the rest. I have tried yur scripts as well no diffrence. I have acpi complied into the kernel I have the kde's batery monitor working just need a couple more things.
Bottom line I cant find the event for the lid. their has to be one becasue it worked on xp. |
|
Back to top |
|
|
friday n00b
Joined: 07 Feb 2003 Posts: 28 Location: Germany
|
Posted: Sat Nov 08, 2003 5:55 pm Post subject: |
|
|
Have a look at 'dmesg | grep ACPI'.
Maybe it tells you that your Hardware is not supported or sth. similar.
Try to find solutions with google. Search for your laptop model and linux and acpi.
HTH |
|
Back to top |
|
|
crisscross n00b
Joined: 21 Aug 2003 Posts: 24
|
Posted: Sat Nov 08, 2003 6:50 pm Post subject: |
|
|
OK I'll do some checking thanks for your help. |
|
Back to top |
|
|
ed0n l33t
Joined: 23 Apr 2003 Posts: 638 Location: Prishtine/Kosove
|
Posted: Sat Nov 08, 2003 10:41 pm Post subject: |
|
|
thanks. |
|
Back to top |
|
|
gcasillo l33t
Joined: 23 Sep 2003 Posts: 739 Location: Cincinnati, Ohio, USA
|
Posted: Fri Nov 14, 2003 9:01 pm Post subject: |
|
|
A hearty thanks for your contribution, Friday. I'm going to give PowerNowd a looksy now to see if I can temper my laptop's tendency to run too hot when compiling large programs. It has shutdown from the heat several times already, and I just had to replace its hard drive this week. |
|
Back to top |
|
|
bdraw n00b
Joined: 24 Nov 2003 Posts: 21 Location: Tampa
|
Posted: Thu Dec 11, 2003 3:25 pm Post subject: |
|
|
I have worked on this for a few days. No luck
I am very new to bash scirpting.
I want my laptop screen to turn off and the xscreensaver to throttle when I close the lid. I would also like the oposite to happen when I open it.
So I edited my script.
Code: |
XSCREENSAVER="/usr/bin/xscreensaver-command"
# lid closed
# When the lid closes throttle xscreensaver when it opens unthrottle it.
btn_lid ()
{
if grep -q open $LID_STATE
then
$LOGGER "[acpid] Lid opened"
$XSCREENSAVER --unthrottle
else
$LOGGER "[acpid] Lid closed"
$XSET dpms force off
$XSCREENSAVER --throttle
fi
}
|
I did not change anything else in the script and my logs show
Code: |
ACPI action lid is not defined
[acpid] Lid closed
ACPI action lid is not defined
|
What else do I need to do to make this work? _________________ If it's too easy it's boring.
Ben |
|
Back to top |
|
|
|