Exposing the mouse battery status through HAL

Andrei Yurkevich urruru at ru.ru
Tue Nov 30 10:05:34 PST 2004


David Zeuthen wrote:

>On Tue, 2004-11-30 at 16:41 +0000, Sergey Udaltsov wrote:
>  
>
>>I would like to hack HAL a bit in order to add support for the
>>wireless mouse battery status indication. As a basis, I'm going to
>>take some code from lmctl utility (so, for a moment, this could would
>>only support Logitech mice). My question is whether HAL is a proper
>>place for it - and what would be the good starting point(s) to look
>>at? Any advices/comments would be appreciated.
>>
>>    
>>
>I think it makes sense for hal to export this kind of information. Right
>now hal doesn't really do as much for input devices as it could, but
>that is another thing that I want to fix. We do export the capability
>'input'; in the future we should export 'input.mouse', 'input.keyboard'
>and so forth.
>
Perhaps in this particular case it is better to rely on some device's 
capability of having a rechargeable battery - in this case it would be 
possible to have a unified battery charge level/lifetime monitor for 
different battery-powered devices in the system - think of wireless 
mice, keyboards, PDAs, digital cameras and whatever else.

>Anyway, polling for battery status on Logitech wireless mice seems like
>a thing the hal daemon shouldn't do as it's fairly specific for a single
>vendor. However I think it makes good sense for hal to export the
>information as properties. As such, I think the thing to do is to create
>a separate daemon, let's call it mousebatd to do this.
>
>The daemon mousebatd would use libhal to detect devices as well as
>setting the capability input.mouse.wireless and export properties, say
>input.mouse.wireless.battery_level on the hal device object as
>appropriate. The battery_level property would probably be of type
>double. Implementation-wise, mousebatd would also check usb.vendor_id
>and usb.product_id as appropriate to only match the right devices.
>
>Ideally mousebatd should only be running when there is an appropriate
>device (e.g. Logitech wireless mouse) connected to the system we should
>monitor; for the moment it would make sense to use hal callouts (device
>add/device remove) to activate/deactivate the daemon. I'm hoping D-BUS
>activation on the system bus level with some clever rules will make this
>automatic at some point, e.g. we could say 'mousebatd should run if and
>only if a) org.fd.Hal is up; b) there is a Logitech wireless mouse.
>
Again, such a daemon could listen to device activation/deactivation 
callouts from HAL and start/stop monitoring the devices' battery once a 
known device is added/removed. Supporting new devices then would be just 
a matter of adding backends/modules/whatever for that daemon that would 
define how to read battery information from some particular device. In 
turn, the daemon could send out messages thru D-BUS to anyone interested 
in devices' battery status - panel applets/notifications or whatever.

cheers,
Andrei

_______________________________________________
hal mailing list
hal at freedesktop.org
http://freedesktop.org/mailman/listinfo/hal



More information about the Hal mailing list