Exposing the mouse battery status through HAL

David Zeuthen david at fubar.dk
Tue Nov 30 09:14:16 PST 2004


On Tue, 2004-11-30 at 16:41 +0000, Sergey Udaltsov wrote:
> Hi all
> 
> 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.
> 

Hi,

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. At one point we also exported PS/2 devices and the like,
we should do this again as we only export USB devices. Right now, this
is what it looks like

 http://fubar.dk/hal-input.png

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. 

I think this approach is nice because if other vendors than Logitech
want to ship such a daemon they now what properties to export.

FWIW, I'd be happy to remove such code in the hal CVS and hal tarball -
it looks like a cool and useful idea.

Thanks,
David


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



More information about the Hal mailing list