View Single Post
Posts: 236 | Thanked: 223 times | Joined on Oct 2009 @ NE UK
#7
This won't be a massive help with either 2) or 3), but I did notice just now that using

lshal -m

you get continuously updated data on changes detected by the hal daemon.

~# lshal -m

Start monitoring devicelist:
-------------------------------------------------
01:17:36.433: platform_slide property button.state.value = false
01:17:36.629: platform_slide condition ButtonPressed = cover
01:17:37.119: bme property battery.reporting.current = 419 (0x1a3)
01:17:37.164: bme property battery.charge_level.percentage = 33 (0x21)
01:17:54.022: platform_slide property button.state.value = true
01:17:54.049: platform_slide condition ButtonPressed = cover
...
If I run

lshal -m -u /org/freedesktop/Hal/devices/bme

I tell lshal to only show messages about the bme device (this is the bit that monitors the battery, it seems).

Actually, when you run this, for reasons I don't understand, you get a full list from lshal before the monitoring starts. But when it does start, you get to see only messages about the bme.

I'm not suggesting you run this as a shell command inside your program!

Maybe you could think about doing what lshal does in order to accomplish this. The source code is available (a quick google found http://www.koders.com/c/fid5039F7523...99C106B3D.aspx but there's probably a more canonical source)

lshal is hooking into libhal, which is available for you to use on the N900. Maybe you could get libhal to talk to your program when the battery status changes using the function documented here: http://maemo.org/api_refs/4.1/hal-0....perty-modified

I don't know for sure this is the way to do it (you have more experience programming for the N900 than I do! ) but I'd be looking at doing something like that if I tried it. Just some ideas to get you thinking
 

The Following 2 Users Say Thank You to kwotski For This Useful Post: