Battery Monitoring Dotpup for JWM

Stuff that has yet to be sorted into a category.
Message
Author
brad_chuck
Posts: 286
Joined: Tue 16 Aug 2005, 03:47
Location: Appalachian Mountains

Battery Monitoring Dotpup for JWM

#1 Post by brad_chuck »

UPDATE Feb 26 2007

In addition to the regular batmon script I added a totally redone program( batmon-0.1.0 ). This uses GINS to have a GTK 2 look to it. This also changes color ( green to yellow to red )

Just for testers





This is a dotpup for batmon.

batmon is a simple program that shows the status of your battery in the taskbar of JWM. The dopup installs batmon and a script that sets it up for you.

To install just install the dotpup and click on the batmonsetup.sh script in the ROX window that pops up at the end. Then just restart JWM and your batmon should be in your JWM taskbar.

The setup script (batmonsetup.sh)

1. loads modules for your battery
2. Edits your init scripts so that the modules will be loaded at boot time
3. If you have a Toshiba laptop will install modules and set up LCD control script.
4. Adds the batmon program to the JWM task bar.

This dotpup should be rock solid but it may have bugs.

Below is a picture of what it should look like.

If added to the main distro the delivery method could be in the menu of freememapplet. There is also a picture of what this could look like. The dotpup does not edit freememapplet.

Please test!
Attachments
batmon-0.1.0.tar.gz
(2.44 KiB) Downloaded 2036 times
batmon0.0.7.pup
(21.92 KiB) Downloaded 2674 times
batmon1.png
(3.87 KiB) Downloaded 8128 times
batmon2.png
(3.04 KiB) Downloaded 7910 times
Last edited by brad_chuck on Mon 26 Feb 2007, 19:02, edited 7 times in total.

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#2 Post by plinej »

all it did for me was put a "-%" with no number next to blinky. I currently have my laptop unplugged running off the battery. I have battery modprobed and can see my charge left with wmpower.

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#3 Post by plinej »

I see why too. You're batmon.sh is looking for BAT1 but mine is BAT0.

brad_chuck
Posts: 286
Joined: Tue 16 Aug 2005, 03:47
Location: Appalachian Mountains

Great thanks

#4 Post by brad_chuck »

Thanks. I almost added some code to deal with that but did not.

I will go back and fix it.

do you have /proc/acpi/ac_adapter/ADP1/state or /proc/acpi/ac_adapter/ADP0/state ?

More Testers?

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#5 Post by plinej »

nope, this works though:

---------------------------------------------------------------------

#!/bin/sh

cd /proc/acpi/battery/
for a in `ls`
do
rc="`cat /proc/acpi/battery/$a/state | grep "remaining capacity:" | sed -n 's/remaining capacity: //p' | sed -n 's/ mWh//p'`"
cap="`cat /proc/acpi/battery/$a/info | grep "last full cap" | sed -n 's/last full capacity: //p' | sed -n 's/ mWh//p'`"
done
cd /proc/acpi/ac_adapter/
for a in `ls`
do
let "per=(($rc*100)/($cap))"
if [ "`cat /proc/acpi/ac_adapter/$a/state | grep "on-line"`" == "" ]; then
acon="-"
else
acon="+"
fi
done
echo -n "${acon}${per}%"

----------------------------------------------------------------------------------------

you'll need to enter the following commands

modprobe battery
modprobe ac
batmon.sh
Last edited by plinej on Fri 03 Nov 2006, 04:31, edited 2 times in total.

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#6 Post by plinej »

BTW, I don't have ADP0 or ADP1, I have AC.

My revision on your script would obviously only take the first directory in `ls` but you should only have one anyway right?

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#7 Post by plinej »

Whoops, had the wrong directory for the 2nd part of your script but I revised my post to correct that.

brad_chuck
Posts: 286
Joined: Tue 16 Aug 2005, 03:47
Location: Appalachian Mountains

yeah fixed it

#8 Post by brad_chuck »

Yeah I caught it.. This edit works for me so I updated the file on the main post.

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#9 Post by plinej »

It's still the same file for download.

Okay, now it's fixed. Thanks alot for this!

brad_chuck
Posts: 286
Joined: Tue 16 Aug 2005, 03:47
Location: Appalachian Mountains

clean ups

#10 Post by brad_chuck »

Updated the file for download.

Now black on green. Easy to read.

Also added picture.

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#11 Post by BarryK »

This is great!
Just a thought, you don't have to do it -- why not combine with freememapplet
and share the same display, flip between the two every few seconds. Maybe you could even combine the Bash script to return both informations. This would be
one less background daemon polling and taking up cpu time.

Note, MU has a modified version of freememapplet that ...well, I can't
remember exactly but it doesn't display a normal window, enables display
of a more compact window that is less than the full height of the taskbar.
But there were problems I think with how it has to be entered into .jwmrc.
...anyway, MU can give further details!

JB4x4
Posts: 256
Joined: Sun 30 Jul 2006, 22:44
Contact:

#12 Post by JB4x4 »

Great little program, one thing though..

The battery in my laptop lists capacity as "mAh" instead of "mWh". I had to change the script accordingly to have it read. Would there be way to add this into the script?

JB4x4
Posts: 256
Joined: Sun 30 Jul 2006, 22:44
Contact:

#13 Post by JB4x4 »

double post
Last edited by JB4x4 on Sat 04 Nov 2006, 01:45, edited 1 time in total.

User avatar
MU
Posts: 13649
Joined: Wed 24 Aug 2005, 16:52
Location: Karlsruhe, Germany
Contact:

#14 Post by MU »

BarryK wrote:Note, MU has a modified version of freememapplet that ...well, I can't
remember exactly but it doesn't display a normal window, enables display
of a more compact window that is less than the full height of the taskbar.
But there were problems I think with how it has to be entered into .jwmrc.
...anyway, MU can give further details!
It is a very small modification.
The applet is not displayed in a Gtk-window, but in an "eggtray". This is a technique, that it is displayed automatically as a trayicon in the tray-area.
Like this it can be used in Icewm and KDE, too.

details:
http://www.murga.org/~puppy/viewtopic.php?t=4208

Mark

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#15 Post by plinej »

I made a dotpup that includes a pre-install script that writes the necessary lines to your .jwmrc-tray file (it greps for batmon first and if it finds that than it exits). I modified the batmon.sh script again so it should work for JB4x4. After installing the dotpup you of course need to restart JWM to see batmon in your dotpup menu. Click on it and it will automatically modprobe battery & ac and start batmon. You'll then need to restart JWM again to see the percentage in your taskbar.

Thanks again brad, I've been wanting something like this for jwm.

I removed this dotpup because Brad updated the package.
Last edited by plinej on Fri 03 Nov 2006, 19:37, edited 1 time in total.

kirk
Posts: 1553
Joined: Fri 11 Nov 2005, 19:04
Location: florida

#16 Post by kirk »

Just tried the dotpup. Works for me!

I'm running 2.12 beta. When I ran "Batmon" from the DotPups menu, a window popped up saying that the zdrv file was being copied to the same place as my pup_save file. It just sat there for a while, probably because there's just a couple Mbytes left on that partition. So I clicked in the corner to close the window and the computer rebooted. When I ran "Batmon" from the DotPups menu again, the percent of battery showed up in the task bar.

Maybe a 2.12 bug?

Thnaks!

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#17 Post by plinej »

Might be, I'm in 2.11 right now.

Rickrandom
Posts: 195
Joined: Sat 21 Jan 2006, 05:35
Location: Bedfordshire, UK

#18 Post by Rickrandom »

I installed the dotpup, but just got the -%.

I tried in a terminal modprobe battery and modprobe ac (both seemed OK) and batmon.sh (some errors).

I've restarted JWM a couple of times.

I got confused about what to click, etc. Any suggestions?

Puppy 2.10, frugal install.

brad_chuck
Posts: 286
Joined: Tue 16 Aug 2005, 03:47
Location: Appalachian Mountains

#19 Post by brad_chuck »

I updated the main post again with some updated work. This time the main executable will alternate between battery status and free memory. By default it switches about every 10 seconds or so.

Also I fixed the script so that the problem with the

brad_chuck
Posts: 286
Joined: Tue 16 Aug 2005, 03:47
Location: Appalachian Mountains

idea

#20 Post by brad_chuck »

Rickrandom, Try the new batmon-0.0.2.tar.gz first then if that does not work copy and paste the exact error message and I will try to work it out.

I just had an idea..... What do you guys think?

If we made the batmon into a front for a shell script that could control it

so say you could do something like

Code: Select all

while [ 1 ] ;do
batmon -bg #000000 -fg #ffffff `batmon.sh`
sleep 10
batmon -bg #000000 -fg #ffffff `getfreemem.sh`
sleep 10
done
this way you could just update the shell script and bam it would do your bidding. Flash when battery is low or when it goes below freezing whatever.

Temperature , stock prices.........

Post Reply