[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how make my laptop beep when low battery?

On Thu, Mar 26, 2009 at 10:38:05PM -0700, paragasu wrote:
> I am using ACPI debian testing with linux kernel 2.6.26-1-686, the
> problem is, there is no warning when the battery is low.
> Is there a way to make a warning beep whenever my laptop battery low?

On my system data on the battery state is available under /proc/acpi/,

    $  cat /proc/acpi/battery/BAT1/info
    present:                 yes
    design capacity:         4000 mAh
    last full capacity:      4000 mAh
    battery technology:      rechargeable
    design voltage:          14800 mV
    design capacity warning: 420 mAh
    design capacity low:     156 mAh
    capacity granularity 1:  264 mAh
    capacity granularity 2:  3780 mAh
    model number:            PA3206U 
    serial number:           3658Q
    battery type:            Li-Ion
    OEM info:                COMPAL    


    $  cat /proc/acpi/battery/BAT1/state
    present:                 yes
    capacity state:          ok
    charging state:          discharging
    present rate:            0 mA
    remaining capacity:      3960 mAh
    present voltage:         16277 mV

Here's an attempt at a script to use the remaining capacity as
an "alarm", with an arbitrary setpoint:

    awk -vSP=$SETPOINT '/capacity/ && $3<SP{print "beep"}' \

The action here is just to print "beep", so replace that with something
that makes a sound.  The beep package provides /usr/bin/beep, which can
beep at selected frequency and duration, e.g:

    awk -vSP=$SETPOINT '/capacity/ && $3<SP{system("/usr/bin/beep")}' \

If you figure out the right proc file to use, choose a setpoint,
aptitude install beep, and put this in your crontab to run every 
minute or so, maybe it'll do what you want.

Good luck!


Ken Irving

Reply to: