commit | author | age
|
0a148d
|
1 |
#!/bin/ksh |
OB |
2 |
|
|
3 |
UDI="/org/freedesktop/Hal/devices/pseudo/acpi_drv_0_battery0_0" |
|
4 |
|
|
5 |
halout=$(/usr/sbin/lshal -l -u ${UDI}) |
|
6 |
|
|
7 |
perc=$(printf "${halout}" | nawk '$1~/battery.charge_level.percentage/ { print $3 }') |
|
8 |
if [ x$(printf "${halout}" | nawk '$1~/battery.rechargeable.is_charging/ { print $3 }') == xtrue ]; then |
|
9 |
string="battery is charging" |
|
10 |
cstring="charge time" |
|
11 |
elif [ x$(printf "${halout}" | nawk '$1~/battery.rechargeable.is_discharging/ { print $3 }') == xtrue ]; then |
|
12 |
string="battery is discharging" |
|
13 |
cstring="run time" |
|
14 |
else |
|
15 |
string="battery is charged and runs on external power" |
|
16 |
cstring="run time" |
|
17 |
fi |
|
18 |
runtime=$(( $(printf "${halout}" | nawk '$1~/battery.remaining_time/ { print $3 }') / 60 )) |
|
19 |
|
|
20 |
printf "I: the %s at %s%%, expected %s is %i min.\n" "$string" $perc "$cstring" $runtime |
|
21 |
|