Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Check battery status from the command line UNIX

A useful script I came across because, well, I needed it recently -- my laptop's screen was dead, I was in via ssh, and I needed to check on my remaining power. Goran Larsson has written battery, which provides you command-line access to the current status of your battery.

[mysa:~] % battery long 
Battery 1 
  Battery:  battery installed, above warning level 
  Charger:  charger not connected, not charging 
  UPS:      UPS not installed 
  Voltage:  11.751V 
  Current:  0.544A (approx 4:49) 
  Capacity: 2.623Ah of 3.488Ah (75.2%) 

You can download battery from Angry Kitchen Appliances. It's a free shell script.

On a related note, you can modify your power settings from the shell using pmset -- see man pmset for details.

    •    
  • Currently 3.40 / 5
  You rated: 4 / 5 (5 votes cast)
 
[21,177 views]  

Check battery status from the command line | 3 comments | Create New Account
Click here to return to the 'Check battery status from the command line' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Check battery status from the command line
Authored by: danchao on Oct 13, '03 01:51:22PM

if you can't reach the web site, try google page cache at
http://216.239.57.104/search?q=cache:-1bpQtt1ga0J:www.mitt-eget.com/software/macosx/battery/battery+



[ Reply to This | # ]
previous hint
Authored by: hayne on Oct 14, '03 02:47:55PM
This previous hint has lots of comments from people who had run a less sophisticated version of this script. You might find it useful to look at the battery stats reported by these people to get an idea of the range of values that occur.

[ Reply to This | # ]
Check battery status from the command line
Authored by: dickg on Jul 02, '11 03:49:59PM

For use on systems with no battery, the expr variables need to be initialized. The following is recommended:
$ diff battery new.battery
13a14
> # Version 1.5 2011-07-01 expr fix (initialize values) [Dick Guertin]
19c20
< VERSION="1.4"
---
> VERSION="1.5"
95a97,105
> # $ battery
> # Battery 1
> # Battery: battery not installed, above warning level
> # Charger: charger not connected, not charging
> # UPS: UPS not installed
> # System:
> # Voltage: 0.000V
> # Current: 0.000A
> # Charge: 0.000Ah of 0.000Ah
197a208
> amperage1=0 ; amperage2=0
504c515
< # 0x00000200 9 7 clam shell is closed
---
> # 0x00000200 9 7 clamshell is closed



[ Reply to This | # ]