Page 4 of 5

Posted: Thu 12 Apr 2007, 21:01
by setecio
Certainly, I'll watch the post for a few days, so post if you want any more info / terminal results / details ...... (just give me beginner instructions.) I wasn't sure whether conky worked or not - I just couldn't see anything referring to 'battery' anywhere ? If it was hidden somewhere? One reading on conky, MPD, said MPD not responding, I'm not sure what that means ?

sh-3.00# apm
sh: apm: command not found
sh-3.00# ls /proc/apm
/proc/apm
sh-3.00#

How can I easily confirm if the laptop uses ACPI or APM ?

Posted: Thu 12 Apr 2007, 22:04
by HairyWill
setecio wrote:One reading on conky, MPD, said MPD not responding, I'm not sure what that means ?[/qote]I think that stands for Music Player Daemon
http://www.musicpd.org/
this isn't included in vanilla puppy and I don't think I've ever seen a dotpup / pet for it
sh-3.00# ls /proc/apm
/proc/apm
sorry I think I meant

Code: Select all

cat /proc/apm
How can I easily confirm if the laptop uses ACPI or APM ?
As you have a file /proc/apm I think you can assume apm support. My laptop does acpi and has a directory in /proc called acpi with a whole load of files inside containing system info.

Posted: Thu 12 Apr 2007, 23:00
by setecio
Battery is now low

sh-3.00# cat /proc/apm
1.16ac 1.2 0x03 0x00 0x02 0x04 3% 3 min
sh-3.00#

Posted: Fri 13 Apr 2007, 00:32
by HairyWill
thanks for that

After I posted last a light bulb came on in my head.
Just because I have acpi it doesn't mean I have to use it.
I changed my kernel boot parameters to include
acpi=off apm=on
and bingo I'm now using apm. For test purposes only as acpi is much more powerful.
so on battery I get

Code: Select all

sh-3.00# cat /proc/apm 
1.16ac 1.2 0x03 0x00 0x00 0x01 55% 29 min
and on charge I get

Code: Select all

sh-3.00# cat /proc/apm                      
1.16ac 1.2 0x03 0x01 0x03 0x09 52% -1 ?
For the record I didn't need to modprobe apm the module was loaded automatically.

Posted: Fri 13 Apr 2007, 01:27
by HairyWill
To make batmon work for apm try replacing the contents of /root/my-applications/bin/batmon.sh with the following. Leaving Brads copyright intact of course.

Code: Select all

per=`awk '{print $7}' /proc/apm | awk -F % '{print $1}'`

if [ $per -lt "6" ]; then
        if [ "`cat /tmp/batmon.warn.txt | grep warned`" == "" ]; then
                Xdialog --msgbox "WARNING! Your battery is low." 0 0 &
                echo "warned" >> /tmp/batmon.warn.txt
        fi      
fi

if [ $per -gt "5" ]; then
        rm /tmp/batmon.warn.txt 2> /dev/null
fi

if [ `awk '{print $8}' /proc/apm` -gt 0 ]
then
        acon="-"
else
        acon="+"
fi

echo -n "${acon}${per}%"
To make a batmon that supports apm and acpi just requires a test for /proc/apm or /proc/acpi before deciding which code to use.

Posted: Fri 13 Apr 2007, 07:52
by setecio
Excellent. I saved a backup copy of existing batmon.sh as batmon.old, and replaced everything after the comments with your new code in the batmon.sh, and the battery level on the green batmon icon in the taskbar is now displaying a perfect % remaining figure.

Thanks for that. :D

When I hover the mouse over it, a little box appears with 'aasdf' in it. Can this be changed or stopped ?

Posted: Fri 13 Apr 2007, 23:00
by brad_chuck
Great work HairyWill and setecio.

Next time I get to it I will make this an option in the batmonsetup.sh program and then folks with APM can use batmon without all this hassle.

I tried sed last night and gave up. Perhaps I should learn awk.....

Anyway thanks for the code.

Posted: Fri 11 May 2007, 08:02
by gdemonta
Hello Brad_chuck,
I tried batmon a few days ago and I got the famous %- problem. Yesterday I noticed the line I had previously added to automatically mount one of my partition didn't function either since that day (I know I'm a bit slow...).
I went to the rc.local file and, wow, I found the batmon line your script added fot modprobing battery had benn added in the same line as my automount! So i just pulsed "enter" to separate both lines and I got the batmon working and my automount working again. It works great!
I also wanted to point out for the icewm users to edit preference in root/.icewm ant activate taskbarAPM something in order to show the batmon.

Posted: Thu 24 Jan 2008, 19:19
by Kezo
Dear all,

I just started to use Puppy3.01 on a FujitsuSiemens K7610W laptop. I made batmon visible on the tray and it shows the good percentage of the battery but if I move the mouse above the tray it shows the "aasdf" which is weird to me...
I would appreciate if anyone had a good idea what to do!

BTW, this is the first Linux what I brave enough to try, but I really like it!

Batmon does not work with 2 batteries

Posted: Tue 26 Feb 2008, 13:35
by MichelC
I run Puppy Linux 3.01 on a Compaq Armada laptop. Batmon used to work perfectly until I add a second battery. I then got -% in the tray.
Running batmon.sh in a terminal window gives the error :
--------------
/usr/local/bin/batmon.sh: line 18: let: per=((2885
2655*100)/(2885
2655)): missing `)' (error token is "2655*100)/(2885
2655))")
---------------
I look at the script and the tmp files and made the following changes to the script to add the values of the two batteries :
--------------
for a in `ls`
do
rc1="`cat /proc/acpi/battery/$a/state | grep "remaining capacity:" | sed -n 's/remaining capacity: //p' | sed -n 's/ m[A-Z]h//p'`"
cap1="`cat /proc/acpi/battery/$a/info | grep "last full cap" | sed -n 's/last full capacity: //p' | sed -n 's/ m[A-Z]h//p'`"
rc="($rc+$rc1)"
cap="($cap+$cap1)"
done
echo $rc >> /tmp/batmon.rc
echo $cap >> /tmp/batmon.cap
----------------
I now get what seems to be ok. I am not a Linux programmer and would like to know if my changes are valid and is there a better way to do it.

Thanks

hexedit

Posted: Tue 26 Feb 2008, 14:37
by raffy
setecio wrote:When I hover the mouse over it, a little box appears with 'aasdf' in it. Can this be changed or stopped ?
You can use hexedit to find and change it.

Posted: Sat 21 Nov 2009, 20:30
by whatshisname
Been trying for a couple of days to get some kind of battery monitoring working with my ancient Dell Inspiron 2600 laptop. Running 4.3.1 Puppy. Previous versions of Puppy worked. Oddly, though, I've tried loading some livecd's of older versions of Puppy and they all present the contents of "/proc/apm" as indicated below.

Have to boot with "acpi=off".

No matter whether the laptop is plugged in or not, "cat /proc/apm" yields:

# more /proc/apm
1.16ac 1.2 0x03 0x01 0xff 0x80 -1% -1 ?

Unless I can get something besides the above, no battery watching script is going to work.

I've tried "modprobe apm" to make sure the module is loaded. Still no joy.

Suggestions anyone?

Thanks.