# Battery life indicator?



## Eponasoft (Aug 26, 2009)

Are there any programs for X (for KDE would be great, something that sits in the Panel) that display the current charge of a laptop's battery? It would be great to know how long until my laptop dies...I used it with just the battery today for the first time ever...got about 2 hours out of the battery (as opposed to barely a half an hour when I used to run XP) but when it was drained, the system just shut off on me...I had no idea how much life the thing had left in it.


----------



## jrick (Aug 26, 2009)

I don't know any GUI applications for this, but you can check it with sysctl: 


```
% sysctl hw.acpi.battery
hw.acpi.battery.life: -1
hw.acpi.battery.time: -1
hw.acpi.battery.state: 7
hw.acpi.battery.units: 1
hw.acpi.battery.info_expire: 5
```

...although my values are currently -1 since I don't have my battery plugged in.


----------



## kpedersen (Aug 26, 2009)

Hello,

In the default gnome install there is. The small blue Power Manager icon in the system tray.

It is exactly not KDE though soz!


----------



## Eponasoft (Aug 26, 2009)

```
$ sysctl hw.acpi.battery
sysctl: unknown oid 'hw.acpi.battery'
```


I have to disable ACPI because the network card won't work with it enabled (stupid Acer). Also, Gnome won't build on my system, and fails to install via ports. Ah well...is there any other method?


----------



## jrick (Aug 26, 2009)

Not that I'm aware of, and even if you could get Gnome installed, it's my guess that it's using ACPI as well.


----------



## Eponasoft (Aug 26, 2009)

Dang.  Oh well...thanks for the help.


----------



## lyuts (Aug 26, 2009)

Take a look at KLaptop.


----------



## kpedersen (Aug 26, 2009)

as far as I recall, before the battery icon was working (FreeBSD 7.0 i think) I used to use...

acpi -i

or 

apm

I cannot quite remember their exact usage, but they both allowed me to output my battery status to the console

If you want that displayed in X, it would be quite easy to make a simple gtk / qt dialog and scrape the data from the console output.


----------



## jrick (Aug 26, 2009)

kpedersen said:
			
		

> If you want that displayed in X, it would be quite easy to make a simple gtk / qt dialog and scrape the data from the console output.



echoing the output to something like dzen2 is even simpler.  This is what I use to see my battery life in my xmonad status bar.


----------



## Eponasoft (Aug 26, 2009)

Hrm...


```
fbsd# apm
apm: can't open /dev/apm: No such file or directory
fbsd# acpi
acpi: Command not found.
```



I'll try klaptopdaemon, thanks for the tip.


----------



## fronclynne (Aug 27, 2009)

*Anything short of licking the terminals.*

Maybe sysutils/xbattbar
Though with apm & acpi disabled, I'm not sure how _anything_ is going to find your battery state.


----------



## morbit (Aug 27, 2009)

> fbsd# acpi
> acpi: Command not found.



acpiconf -i0


----------



## Eponasoft (Aug 28, 2009)

```
$ acpiconf -i0
acpiconf: /dev/acpi: No such file or directory
```


```
$ xbattbar
This is xbattbar version 1.4.2, copyright (c)1998-2001 Suguru Yamaguchi
xbattbar: fall back to apm interface
xbattbar: cannot open apm device
```
 
stupid Acer...


----------



## fronclynne (Aug 28, 2009)

Might try rebuilding your kernel with 
	
	



```
device apm
```
 (I believe this is i386 only).

And good luck.  I don't recall apm working all that well in the 4.x days and I don't know if that code has been updated much since then.


----------



## morbit (Aug 28, 2009)

Maybe it's time to check 8.0-BETA3. There is new acpica.


----------



## Eponasoft (Aug 28, 2009)

Hrm ok...thanks for all the help folks. I'm not a fan of beta-quality software, especially when it's an operating system, so I'll just chill until 8.0 is considered CURRENT, then upgrade.


----------



## jrick (Aug 28, 2009)

Eponasoft said:
			
		

> Hrm ok...thanks for all the help folks. I'm not a fan of beta-quality software, especially when it's an operating system, so I'll just chill until 8.0 is considered CURRENT, then upgrade.



Uh... 8 is -CURRENT. 

(Or maybe it's 9 now?)


----------



## morbit (Aug 28, 2009)

CURRENT is already 9, 8-STABLE is BETA3 now.

http://wiki.freebsd.org/8.0TODO


----------



## DutchDaemon (Aug 28, 2009)

In FreeBSD, 'CURRENT' == 'bleeding edge - high risk'. Pick -RELEASE for production, -STABLE for 'some risk, but usually ok'.


----------



## Eponasoft (Aug 29, 2009)

Oops, my bad...whatever the word is for "recent, most stable, not likely to go crash" hehe.  I guess that would be RELEASE. All the different descriptors are kind of confusing.


----------



## morbit (Aug 29, 2009)

'Safe' and tested changes from CURRENT are backported to STABLE. RELEASE is (usually) cut from STABLE.

http://www.over-yonder.net/~fullermd/rants/bsd4linux/bsd4linux5.php

*If you would like to track CURRENT/STABLE I would recommend using  devel/subversion-freebsd port and subversion repository. It's faster.


----------



## Carpetsmoker (Aug 30, 2009)

This works for me: http://carpetsmoker.net/code/battray/ -- But I may not be completely impartial though


----------



## Eponasoft (Aug 30, 2009)

```
$ ./battray.py
Traceback (most recent call last):
  File "./battray.py", line 103, in <module>
    exec("import %s as p" % sys.platform)
  File "<string>", line 1, in <module>
  File ".//platforms/freebsd7.py", line 15, in <module>
    o = subprocess.Popen(['apm', '-ablt'], stdout=subprocess.PIPE).communicate()[0]
NameError: name 'subprocess' is not defined
```


----------



## Carpetsmoker (Aug 30, 2009)

Oops, I forgot to add a line for platforms/freebsd.py

EDIT:
Ok, I had some spare time:
http://carpetsmoker.net/code/battray/download/battray-1.1.tar.gz

Can you please verify if this works? An early version worked fine on FreeBSD, but I have since switced my laptop to OpenBSD and I don't have a FreeBSD installation to test it anymore ...


----------



## Eponasoft (Aug 31, 2009)

```
$ ./battray.py
apm: can't open /dev/apm: No such file or directory
Traceback (most recent call last):
  File "./battray.py", line 130, in <module>
    exec("import %s as p" % sys.platform)
  File "<string>", line 1, in <module>
  File ".//platforms/freebsd7.py", line 18, in <module>
    (ac, charging, percent, time) = o.split()
ValueError: need more than 0 values to unpack
```
Python isn't my thing so I don't know anything about how to fix it.


----------



## Carpetsmoker (Aug 31, 2009)

It's not a python problem this time, the problem is:


```
apm: can't open /dev/apm: No such file or directory
```

The apm(8) command doesn't seem to work on your laptop ... 

An alternative might be using sysctl, post the output of:
`% sysctl hw.acpi`


----------



## everypot (Aug 31, 2009)

I simply use the Battery widget in KDE4.3.

Also acpiconf -i0 works for me:  

```
acpiconf -i0
Design capacity:        4860 mAh
Last full capacity:     4733 mAh
Technology:             secondary (rechargeable)
Design voltage:         10800 mV
Capacity (warn):        240 mAh
Capacity (low):         144 mAh
Low/warn granularity:   264 mAh
Warn/full granularity:  3780 mAh
Model number:           GC86508SAT0
Serial number:
Type:                   LION
OEM info:               SANYO
State:                  high
Remaining capacity:     100%
Remaining time:         unknown
Present rate:           0 mA
Voltage:                12417 mV
```


----------



## Eponasoft (Sep 3, 2009)

ACPI is disabled on my system, so anything involving ACPI will automatically fail.


----------



## kpedersen (Sep 3, 2009)

Solution:

1) Time exactly how long from full battery, it takes to become flat.

2) Buy a stopwatch (I found a really cheap one here on ebay for you!)
http://cgi.ebay.co.uk/Chronograph-D...in_0?hash=item4148815260&_trksid=p3286.c0.m14

3) Input into the stopwatch, the time it took from step 1

4) Glue that stopwatch to the side of the screen.

The only slight inconvenience with this method is that you MUST remember to pause the stopwatch when you shutdown the computer.

I was going to say get a stop watch with a slow motion function for when you put the computer in hibernate / suspend but that wont work without acpi / apm anyways 

I look forward to reading the updated handbook in the acpi problems section.

Hope this helps.


----------



## Carpetsmoker (Sep 3, 2009)

@kpedersen, haha, that's funny but also kind of strange ... High tech computer and you need to glue a stopwatch to your screen 



			
				Eponasoft said:
			
		

> ACPI is disabled on my system, so anything involving ACPI will automatically fail.



Right, that explains it then. All battery status indicators will fail for you then


----------



## kpedersen (Sep 3, 2009)

@Carpetsmoker,

Strange? I already have a pencil sharpener, pad of paper, pens and some chocolate bars stuck to mine


----------



## Eponasoft (Sep 4, 2009)

kpedersen said:
			
		

> Solution:
> 
> 1) Time exactly how long from full battery, it takes to become flat.
> 
> ...


You know what? As ludicrous and sarcastic as this suggestion is, it's actually the only one that WOULD work.  And it would probably be accurate to about 5 minutes.

Well, here's hoping that 8.0 fixes the ACPI issue...


----------



## aragon (Sep 4, 2009)

Carpetsmoker said:
			
		

> High tech computer and you need to glue a stopwatch to your screen


With broken ACPI, maybe it's not so high tech after all.


----------



## Eponasoft (Sep 4, 2009)

aragon said:
			
		

> With broken ACPI, maybe it's not so high tech after all.


Nah, it's just an Acer...'nuff said.


----------

