1 |
The attached script requires "make menuconfig" to have |
2 |
|
3 |
Power management and ACPI options ---> |
4 |
[*] ACPI (Advanced Configuration and Power Interface) Support ---> |
5 |
<*> Battery |
6 |
|
7 |
or CONFIG_ACPI_BATTERY enabled if you do .config manually. |
8 |
|
9 |
The script reads /sys/class/power_supply/BAT1/uevent on a laptop and |
10 |
calculates the percentage of battery charge. Because it only reads from |
11 |
/sys, and does not write, it can be run by a regular user. The script |
12 |
is primitive, and has to be stopped with {CTRL}{C}. |
13 |
|
14 |
The script runs in text mode, and can run in xterm or even a pure text |
15 |
console. I've removed the #!/bin/bash at the top of the attached file |
16 |
and chmod'ed it non-executable. The mailing list software seems to |
17 |
reject any such attachments. You can source the file as is, or chmod it |
18 |
executable, and insert #!/bin/bash at the top. Note that there is an |
19 |
ANSI escape sequence in the script, to keep the output in one location. |
20 |
Regular cut-and-paste can fail if you try to copy from the screen. |
21 |
|
22 |
-- |
23 |
Walter Dnes <waltdnes@××××××××.org> |
24 |
I don't run "desktop environments"; I run useful applications |