Vattery+IBAM

Miscellaneous tools
Message
Author
User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#16 Post by jemimah »

Yeah fixing that is on my todo list. Perhaps a third color for 'fully charged'.

OverDrive
Posts: 178
Joined: Mon 02 Jan 2006, 05:07
Location: Cleveland, OHIO,USA

#17 Post by OverDrive »

jemimah, That would do it. Then if the user doesn't see that color then they know something is up. Between that and the dialog box popup's, IMHO, we should be good to go. FWIW, I'm using this on my tray instead of asapm just because of the popup's alone.

Best Regards

OverDrive
Instant Puppy Fan!!!

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#18 Post by jemimah »

I've posted a new version that uses the charging color for fully charged batteries instead of the discharging color.

OverDrive
Posts: 178
Joined: Mon 02 Jan 2006, 05:07
Location: Cleveland, OHIO,USA

#19 Post by OverDrive »

Jemimah, That's perfect. Thank you so much. FWIW, I also tested the dialog box's and they also worked quite nicely on my notebook. Hey, If your ever coming to Cleveland, let me know. I'll take you out for some good local chow..


All the Best

OverDrive
Instant Puppy Fan!!!

User avatar
DaveS
Posts: 3685
Joined: Thu 09 Oct 2008, 16:01
Location: UK

#20 Post by DaveS »

Using this on a heavily re-mastered 4.3.1. Very very nice thanks. I have been hoping for a replacement for asapm for sometime as it is so darn ugly. Thanks a million.............
Spup Frugal HD and USB
Root forever!

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#21 Post by jemimah »

I've added a pet for Trayclock. It's an analog clock for the systray by the same developer as Vattery, and it matches nicely.

makerprofaze
Posts: 20
Joined: Sun 03 Jan 2010, 08:40

#22 Post by makerprofaze »

!
Last edited by makerprofaze on Sat 23 Jan 2010, 05:28, edited 1 time in total.

makerprofaze
Posts: 20
Joined: Sun 03 Jan 2010, 08:40

#23 Post by makerprofaze »

I'm using this on 4.31 retro. I had a mystery shutoff the other day and had to reinstall Puppy, very bad thing. It actually left my laptop in a questionable condition (!). First thing I did upon gettitng everything working was start looking for a battery gauge. Vattery has already warned me twice since then, adverting catastrophe - not that I'm sloppy or anything.

Thanks heaps for this. It should be built into the OS. I'm glad I'm new enough to Puppy, cause I would have been pissed without it!

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#24 Post by jemimah »

Glad to help.

I'm working on a cpu temperature monitor based on Vattery code... maybe a whole suite of tray monitors is in the works. The source code is on my website if anyone wants to play with it.

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#25 Post by jemimah »

I've uploaded a new version of Vattery and also a new applet TrayTemp for monitoring your CPU temperature.

ljfr
Posts: 176
Joined: Thu 23 Apr 2009, 08:35

source

#26 Post by ljfr »

Hi jemimah,
where can we find the sources of your latest versions ?
regards,

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#27 Post by jemimah »

There's two mirrors now for sources, http://drop.io/jemimah, and http://puppeee.com/files/sources/. If you have trouble getting them to build, let me know - Valac doesn't really like Puppy's version of gtk.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#28 Post by technosaurus »

stupid script that I wrote:

Code: Select all

#!/bin/bash
BATREMAIN=`grep remaining /proc/acpi/battery/BAT1/state |cut -d " " -f8`
BATFULL=`grep last /proc/acpi/battery/BAT1/info |cut -d " " -f9`
BATPERCENT=$((100*$BATREMAIN/$BATFULL))
BATSTATE=`grep charging /proc/acpi/battery/BAT1/state |cut -d " " -f12`
echo mAh remaining $BATREMAIN
echo mAh capacity $BATFULL
echo percent charged $BATPERCENT
echo the battery is $BATSTATE
Similar things can be done with /proc/acpi/battery/BAT1/* ... this can be a template - just grep for a line with unique string and cut out the string you need from that line (using spaces as the separator or "delimiter")

and for temperature

Code: Select all

CPU0TEMP=`grep temperature /proc/acpi/thermal_zone/TZ00/temperature |cut -d " " -f14`
echo CPU Temperature is $CPU0TEMP
Edit:
Not being sure how things may change it may be best to add
sed "s/: */ /" before cut so that the number of spaces for formatting doesn't change the result
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#29 Post by technosaurus »

I cleaned it up some... may be able to use pieces in a script with your gtrayicon now

Code: Select all

#!/bin/ash
getprocinfo() {
#/proc/file string_number_in_line string_always_in_line_but_not_others
	grep $3 $1 |sed "s/: */ /" |cut -d " " -f $2
}
BATREMAIN=`getprocinfo /proc/acpi/battery/BAT1/state 3 remaining`
BATFULL=`getprocinfo /proc/acpi/battery/BAT1/info 4 last`
echo mAh remaining $BATREMAIN
echo mAh capacity $BATFULL
BATPERCENT=$((100*$BATREMAIN/$BATFULL))
BATSTATE=`getprocinfo /proc/acpi/battery/BAT1/state 3 charging`
echo percent charged $BATPERCENT
echo the battery is $BATSTATE
CPU0TEMP=`getprocinfo /proc/acpi/thermal_zone/TZ00/temperature 2 temp`
echo CPU Temperature is $CPU0TEMP C
LIDSTATUS=`getprocinfo /proc/acpi/button/lid/LID/state 2 state`
echo Lid is $LIDSTATUS
PLUGSTATUS=`getprocinfo /proc/acpi/ac_adapter/ACAD/state 2 state`
echo AC adapter is $PLUGSTATUS
KERNVER=`getprocinfo /proc/version 3 Linux`
echo Your Kernel is version $KERNVER
UPTIMESECS=`getprocinfo /proc/uptime 1 "."`
echo Your computer has been running for $UPTIMESECS seconds
IDLETIMESECS=`getprocinfo /proc/uptime 2 "."`
echo Your computer has been idle for $IDLETIMESECS seconds
MEMTOT=`getprocinfo /proc/meminfo 2 MemTotal`
echo Total RAM is $MEMTOT kb
MEMFREE=`getprocinfo /proc/meminfo 2 MemFree`
echo Total free RAM is $MEMFREE kb
SWPTOT=`getprocinfo /proc/meminfo 2 SwapTotal`
echo Total Swap is $SWPTOT kb
SWPFREE=`getprocinfo /proc/meminfo 2 SwapFree`
echo Total free Swap is $SWPFREE kb
[/code]
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#30 Post by jemimah »

How would you use gtrayicon? It has only two states. Battery full, and battery empty? I supposes you could change the graphics out from underneath it, but it would be a hack, on top of an already quick and dirty kludge. What we should probably do is extend gtrayicon to do this sort of thing properly.

You could use that logic in Vattery, instead of using IBAM, but IBAM gives you a time left estimate, which is rather nice. In fact, I don't know why you wouldn't want to use IBAM in whatever solution you pick, it's not very big.

The only drawback is that it doesn't work on the Eee 701 (and maybe the 900) since their battery doesn't report its status correctly.

Well there is one other drawback, IBAM needs to be "trained." Initial results are really erratic until IBAM gets it's database configured.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#31 Post by technosaurus »

I didn't go through all of the stuff in /proc/acpi/battery/BAT1/state
to get {dis}charge rate using the getprocinfo function from before
BATRATE=`getprocinfo /proc/acpi/battery/BAT1/state 3 rate`
and approximate time remaining in minutes
BATTIME=$(($BATREMAIN*60/$BATRATE))

Barry's Partview script has some code for generating images on the fly using ppmrough and ppmtogif

I was wondering if you could use an embedded xpm, but set the 6 digit data for the colors to be variables

(crude "battery" example)

Code: Select all

/* XPM */
static char *test_xpm[] = {
"24 24 21 1",
"0	c None",
"1	c #FF0000",
"2	c #FF0000",
"3	c #FF0000",
"4	c #FF0000",
"5	c #FF0000",
"6	c #FF0000",
"7	c #FF0000",
"8	c #FF0000",
"9	c #FF0000",
"a	c #FF0000",
"b	c #FF0000",
"c	c #FF0000",
"d	c #FF0000",
"e	c #FF0000",
"f	c #FF0000",
"g	c #FF0000",
"h	c #FF0000",
"i	c #FF0000",
"j	c #FF0000",
"k	c #FF0000",
"000000000000000000000000",
"000000000000000000000000",
"000000111111111111000000",
"000000222222222222000000",
"000000333333333333000000",
"000000444444444444000000",
"000000555555555555000000",
"000000666666666666000000",
"000000777777777777000000",
"000000888888888888000000",
"000000999999999999000000",
"000000aaaaaaaaaaaa000000",
"000000bbbbbbbbbbbb000000",
"000000cccccccccccc000000",
"000000dddddddddddd000000",
"000000eeeeeeeeeeee000000",
"000000ffffffffffff000000",
"000000gggggggggggg000000",
"000000hhhhhhhhhhhh000000",
"000000iiiiiiiiiiii000000",
"000000jjjjjjjjjjjj000000",
"000000kkkkkkkkkkkk000000",
"000000000000000000000000",
"000000000000000000000000"
};
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#32 Post by jemimah »

That time estimate would probably be nowhere near accurate, as batteries aren't very linear. I guess that's what most tools do though. What about laptops with multiple batteries? What about APM?

That might be too cpu heavy to use ppmtogif or whatever Nothing worse than the battery monitor killing your battery life.

You could probably use xpm (gtk definetly supports xpm, or SVG which is also easily generated on the fly [heh, you can copy my code from Vattery]), and just send gtrayicon a signal to update every minute or so. However, I think there's a tool posted on the forum somewhere that already does something very similar to what you're suggesting, and there's the one Barry says he's making.

I personally like Vattery a lot, as it's user configurable, looks nice, it's pretty easy to hack on, and best of all, it's already written. ;)

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#33 Post by technosaurus »

Anyhow now that I have IBAM up and running (works great by the way) this has become a purely educational excercise and something to add to my bash library

not sure about APM (what is it? automatic power management?) - I'd have to look at the cpu scaling code in (can't think of the name) - but if I recall it does the same sort of thing except that it forcibly writes to /proc

Multiple batteries:
for $onedir in `ls /proc/acpi/battery |grep BAT` ...

up next: a bash script to write an xpm that displays a bar representation of percentage using percentage, & maybe{width, height, foreground, background}? but moving it to the bash library thread in "programming"
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
jemimah
Posts: 4307
Joined: Wed 26 Aug 2009, 19:56
Location: Tampa, FL
Contact:

#34 Post by jemimah »

Apm is like old-school acpi. Your battery code would only work on newer laptops. http://tldp.org/HOWTO/Battery-Powered/powermgm.html

Post Reply