• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Battery life indicator?

Eponasoft

Active Member

Thanks: 10
Messages: 218

#1
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

Member

Thanks: 5
Messages: 84

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

Code:
% 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

Aspiring Daemon

Thanks: 219
Messages: 994

#3
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

Active Member

Thanks: 10
Messages: 218

#4
Code:
$ 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

Member

Thanks: 5
Messages: 84

#5
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

Active Member

Thanks: 10
Messages: 218

#6
Dang. :( Oh well...thanks for the help. :)
 

kpedersen

Aspiring Daemon

Thanks: 219
Messages: 994

#8
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

Member

Thanks: 5
Messages: 84

#9
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

Active Member

Thanks: 10
Messages: 218

#10
Hrm...

Code:
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

Daemon

Thanks: 175
Messages: 1,297

#11
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.
 

Eponasoft

Active Member

Thanks: 10
Messages: 218

#13
Code:
$ acpiconf -i0
acpiconf: /dev/acpi: No such file or directory
:(
Code:
$ 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

Daemon

Thanks: 175
Messages: 1,297

#14
Might try rebuilding your kernel with
Code:
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.
 

Eponasoft

Active Member

Thanks: 10
Messages: 218

#16
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

Member

Thanks: 5
Messages: 84

#17
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. :p

(Or maybe it's 9 now?)
 

Eponasoft

Active Member

Thanks: 10
Messages: 218

#20
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. :(
 

Eponasoft

Active Member

Thanks: 10
Messages: 218

#23
Code:
$ ./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

Daemon

Thanks: 180
Messages: 1,010

#24
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

Active Member

Thanks: 10
Messages: 218

#25
Code:
$ ./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. :)