* [gentoo-user] acpi battery events, Sony FS740
@ 2007-01-02 7:27 »Q«
2007-01-03 1:42 ` Iain Buchanan
0 siblings, 1 reply; 4+ messages in thread
From: »Q« @ 2007-01-02 7:27 UTC (permalink / raw
To: gentoo-user
I'm nearly a complete newbie to power management. I've been reading
and tinkering for the past three days. I'm not sure I know enough to
explain my problem clearly, but I'll be glad to try to clarify or post
more info if you can steer me a bit.
I have a Sony Vaio FS740 laptop, and I have power management set up
mostly to my liking, but with one problem. ACPI receives battery
events when the AC is connect and when it is unconnected, but also at
other times, and I don't know how to distinguish. If there are no
actions for acpid to take when they happen, the
script /etc/acpi/default.sh sends this to the syslog:
logger: ACPI event unhandled: battery BAT0 00000080 00000001
logger: ACPI event unhandled: battery BAT0 00000080 00000001
They come in pairs, and the string is the same whether the cord has
just been attached or removed or neither.
I have an acpid event/action which catches these and then sets the
brightness level depending on whether or not the cord is plugged in.
This works fine when I switch between AC and battery power. The
problem is that if I want to set some other brightness level manually,
it does no good, because one of the I-don't-know-why-they-happen
battery events will trigger a change in brightness within a couple of
minutes.
Here's the event file for acpid, /etc/acpi/events/pmg_brightness :
-----
event=battery.*
action=/etc/acpi/actions/pmg_change_brightness.sh %e
-----
And here's /etc/acpi/actions/pmg_change_brightness.sh :
-----
#!/bin/bash
# this line was added in hopes of debugging,
# but I see no help from it.
logger "brightness script caught: ${*}"
BRIGHTNESS_AC="4"
BRIGHTNESS_BATTERY="1"
if on_ac_power
then
logger "Setting LCD to brightness ${BRIGHTNESS_AC}"
echo $BRIGHTNESS_AC > /proc/acpi/sony/brightness
else
logger "Setting LCD to brightness ${BRIGHTNESS_BATTERY}"
echo $BRIGHTNESS_BATTERY > /proc/acpi/sony/brightness
fi
-----
Whether it's triggered by unplugging or by I-don't-know-what, I get
this in the syslog:
logger: brightness script caught: battery BAT0 00000080 00000001
logger: Setting LCD to brightness 1
Same thing for plugging in or I-don't-know-what, except the brightness
is set to 4 as expected.
I'd appreciate any insight or help you can give me.
--
»Q«
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] acpi battery events, Sony FS740
2007-01-02 7:27 [gentoo-user] acpi battery events, Sony FS740 »Q«
@ 2007-01-03 1:42 ` Iain Buchanan
2007-01-04 1:46 ` [gentoo-user] " »Q«
0 siblings, 1 reply; 4+ messages in thread
From: Iain Buchanan @ 2007-01-03 1:42 UTC (permalink / raw
To: gentoo-user
On Tue, 2007-01-02 at 01:27 -0600, »Q« wrote:
> I'm nearly a complete newbie to power management. I've been reading
> and tinkering for the past three days. I'm not sure I know enough to
> explain my problem clearly, but I'll be glad to try to clarify or post
> more info if you can steer me a bit.
>
> I have a Sony Vaio FS740 laptop, and I have power management set up
> mostly to my liking, but with one problem. ACPI receives battery
> events when the AC is connect and when it is unconnected, but also at
> other times, and I don't know how to distinguish. If there are no
> actions for acpid to take when they happen, the
> script /etc/acpi/default.sh sends this to the syslog:
>
> logger: ACPI event unhandled: battery BAT0 00000080 00000001
> logger: ACPI event unhandled: battery BAT0 00000080 00000001
It could be a number of things - perhaps you have a faulty cable /
connection, which is causing ACPI events because it thinks it's just
been unplugged, and replugged.
Or perhaps your thinkpad sends ACPI events when the battery has reached
certain charge levels... don't know - someone with the same laptop will
have to comment.
Do these spontaneous ACPI events only happen when plugged in? or only
when unplugged, or both?
To get around it, perhaps you could keep "state" with a file. eg
(untested):
-----
BRIGHTNESS_AC="4"
BRIGHTNESS_BATTERY="1"
ALREADY_PLUGGED_IN="/.power"
if on_ac_power
then
if -f ${ALREADY_PLUGGED_IN} then
logger "Recieved ACPI power event, but already plugged in!"
else
logger "Setting LCD to brightness ${BRIGHTNESS_AC}"
echo $BRIGHTNESS_AC > /proc/acpi/sony/brightness
touch ${ALREADY_PLUGGED_IN}
fi
else
logger "Setting LCD to brightness ${BRIGHTNESS_BATTERY}"
echo $BRIGHTNESS_BATTERY > /proc/acpi/sony/brightness
rm ${ALREADY_PLUGGED_IN}
fi
-----
This will only work for the already-plugged-in-acpi-event, you may have
to do a bit of playing if you also get an already-unplugged-acpi-event,
but I have to leave some fun for you!
HTH!
--
Iain Buchanan <iaindb at netspace dot net dot au>
It is better to have loved and lost -- much better.
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 4+ messages in thread
* [gentoo-user] Re: acpi battery events, Sony FS740
2007-01-03 1:42 ` Iain Buchanan
@ 2007-01-04 1:46 ` »Q«
2007-01-04 2:16 ` Iain Buchanan
0 siblings, 1 reply; 4+ messages in thread
From: »Q« @ 2007-01-04 1:46 UTC (permalink / raw
To: gentoo-user
Iain Buchanan wrote:
> On Tue, 2007-01-02 at 01:27 -0600, »Q« wrote:
>
> > I have a Sony Vaio FS740 laptop, and I have power management set up
> > mostly to my liking, but with one problem. ACPI receives battery
> > events when the AC is connect and when it is unconnected, but also
> > at other times, and I don't know how to distinguish.
>
> It could be a number of things - perhaps you have a faulty cable /
> connection, which is causing ACPI events because it thinks it's just
> been unplugged, and replugged.
>
> Or perhaps your thinkpad sends ACPI events when the battery has
> reached certain charge levels... don't know - someone with the same
> laptop will have to comment.
>
> Do these spontaneous ACPI events only happen when plugged in? or only
> when unplugged, or both?
.
They happen whether or not it's plugged in. Sony won't tell anybody
how their ACPI stuff works, and AFAICT from some more googling, no one
is sure exactly what is going on with any given model.
> To get around it, perhaps you could keep "state" with a file. eg
> (untested):
[big snip]
> HTH!
It certainly did; thanks very much! After some tinkering (my
understanding of testing syntax in bash scripts is pretty weak), I've
got the scheme you suggested working fine.
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-user] Re: acpi battery events, Sony FS740
2007-01-04 1:46 ` [gentoo-user] " »Q«
@ 2007-01-04 2:16 ` Iain Buchanan
0 siblings, 0 replies; 4+ messages in thread
From: Iain Buchanan @ 2007-01-04 2:16 UTC (permalink / raw
To: gentoo-user
On Wed, 2007-01-03 at 19:46 -0600, »Q« wrote:
> Iain Buchanan wrote:
>
> > To get around it, perhaps you could keep "state" with a file. eg
> > (untested):
>
> [big snip]
>
> > HTH!
>
> It certainly did; thanks very much! After some tinkering (my
> understanding of testing syntax in bash scripts is pretty weak), I've
> got the scheme you suggested working fine.
cool, thanks for letting me know! glad I could help.
I just had a thought though - the file you use should probably go
somewhere more sane, like /var/run or something like that.
cya,
--
Iain Buchanan <iaindb at netspace dot net dot au>
I'm sure a mathematician would claim that 0 and 1 are both very
interesting numbers. :-)
-- Larry Wall in <199707300650.XAA05515@wall.org>
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-01-04 2:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-02 7:27 [gentoo-user] acpi battery events, Sony FS740 »Q«
2007-01-03 1:42 ` Iain Buchanan
2007-01-04 1:46 ` [gentoo-user] " »Q«
2007-01-04 2:16 ` Iain Buchanan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox