Find all attached keyboars and mice

Dan Nicholson dbn.lists at gmail.com
Fri Jan 23 20:35:45 PST 2009


On Fri, Jan 23, 2009 at 7:10 PM, Ahmad Syukri bin Abdollah
<syockit at gmail.com> wrote:
> On Sat, Jan 24, 2009 at 10:31 AM, Yan Seiner <yan at seiner.com> wrote:
>> How do I go about finding all keyboards and mice that are attached to a
>> system?
>>
>
> How about this:
> hal-find-by-capability --capability input
>
> It lists all udi for devices found by the daemon, provided they're in
> hal's known device list. Then you can use
> hal-device [udi]
> for the properties.

For example:

mice=`hal-find-by-capability --capability input.mouse`
for m in $mice; do
    mice_dev="$mice_dev `hal-get-property --udi $m --key input.device`"
done
keyboards=`hal-find-by-capability --capability input.keyboard`
for k in $keyboards; do
    keyboard_dev="$keyboard_dev `hal-get-property --udi $m --key input.device`"
done

Of course, if your program is in C or Python, you can do things much
more powerfully.

--
Dan


More information about the hal mailing list