Recent Widgets


Register for DashboardWidgets

Recent Forums Posts

Partners


iCompositions

MacDesktops.net

RSS Showcase
RSS Comments
RSS Forums

This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. Posted in: Widget Central

Battery Help

Author Message
google636



Joined: 27 Jan 2005
Posts: 17

Posted: Sat Apr 30, 2005 - 4:56 pm    Post subject: Battery Help Reply with quote

I'm working on a battery status widget, but I don't have a 'Book and I'm having trouble utilizing system calls into widgets.

Anyway, would somebody be able to post a javsacript snippet to get battery data? I can code all the javascript, css, etc to make it work, but I need basic raw data, mainly the percentage left, but I might add more features in the future like plugged in/not, battery time left, and a message if the user doesn't have a battery (a desktop mac)

I'm thinking it would be something along the lines of:
Code:

bat = widget.system("ioreg -p IODeviceTree -n \"battery\" -w 0 | grep IOBatteryInfo | awk '{ split($0,a,\",\"); split(a[1],b,\"=\"); split(a[4],c,\"=\");print (c[2] / b[3]) * 100;}'

????????
View user's profile Send private message Widgets
sean



Joined: 22 Apr 2005
Posts: 67
Location: Duluth, MN

Posted: Sat Apr 30, 2005 - 6:57 pm    Post subject: Reply with quote

Code:
ioreg -l | grep -i IOBatteryInfo


is what I use for battery info. Not sure if this helps, because it may very well return about the same as your method, but here's what it outputs:

Code:
    | | |   "IOBatteryInfo" = ({"Capacity"=2775,"Amperage"=0,"Cycle Count"=289,"Current"=2748,"Voltage"=12358,"Flags"=1090519045,"AbsoluteMaxCapacity"=4400})
    | |   |   |     "IOBatteryInfo" = ({"Capacity"=2775,"Amperage"=0,"Cycle Count"=289,"Current"=2748,"Voltage"=12358,"Flags"=1090519045,"AbsoluteMaxCapacity"=4400})


I would love to help, but I'm heading out for the evening. Maybe tomorrow if no one else has volunteered.
View user's profile Send private message Send e-mail Visit poster's website Widgets
claudio



Joined: 01 May 2005
Posts: 1
Location: Italy

Posted: Sun May 01, 2005 - 9:01 am    Post subject: Reply with quote

Hi, i've already developed one myself.
Take a look at

http://www.emeraldion.it/software/widgets/batterystatus

Comments and/or suggestions are welcome.

BTW, is there a way to publish my widget in the front page? Very Happy
View user's profile Send private message Send e-mail Visit poster's website AIM Address Widgets
google636



Joined: 27 Jan 2005
Posts: 17

Posted: Sun May 01, 2005 - 9:25 am    Post subject: Reply with quote

Nice widget. doesn't work for me (with imac), I think it should have an icon so it looks cool on desktop macs too (perhaps a power cord). I feel like copying and pasting the "fetch" functions...hmm...I'll debate it. I'll be sure to give you credit if I do.

To get it posted in the showcase, just go to showcase and upload it. after a couple hours, it will appear, and you'll have beat me in making a battery status widget Very Happy
View user's profile Send private message Widgets
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.

 
Powered by phpBB © 2001, 2002 phpBB Group