GNOME Bugzilla – Bug 383865
support for hotplugging keyboards
Last modified: 2009-01-19 19:15:42 UTC
gnome-power-manager only fetches HAL's list of devices with buttons when it starts up. If a keyboard device appears while gnome-power-manager is running, then it won't notice the power button being pressed on that keyboard. I actually have a use for this. :-) The "mouseemu" program can be used on Macs to emulate the middle and right mouse buttons in a configurable way (e.g. F11 and F12, or Ctrl-click, or whatever); it replaces the sysctl hack we used to use for this by using the uinput facility in Linux 2.6 to create virtual keyboard and mouse devices. When using this, all keyboard and mouse events are captured and either swallowed or replayed over the virtual devices, possibly in a modified form. However, the virtual devices only appear once mouseemu starts, and if this happens after gnome-power-manager starts then gnome-power-manager won't know about the new keyboard device, but no events are going to show up on the old keyboard device any more so it won't be able to handle the power button. This was originally https://launchpad.net/distros/ubuntu/+source/mouseemu/+bug/67954; you need to be apply mouseemu and hal patches in order for hal to pick up the virtual input devices (just setting the uinput bus type to BUS_VIRTUAL (0x06) and making hal's probe-input component accept that), but all the necessary patches are in the Ubuntu Feisty development archive as of today if you want to try it out. I've been trying to fix this problem for a few hours, and I nearly managed it. My work-in-progress patch will be attached in a moment, mostly cribbed from gpm-battery.c. Unfortunately, for some reason I can't determine, when hal_device_added_cb is called gpm_hal_device_has_capability claims that the new device doesn't have the "button" capability, even though running "hal-device" shortly afterwards lists it in info.capabilities. If you can figure this out or suggest a workaround, that would be great.
Created attachment 77988 [details] [review] partial button hotplug support
Sorry for the delay, busy week. Looks good on quick review. Why do you suggest using g_idle_add ((GSourceFunc)start_idle, button);? Thanks.
I was copying gpm-battery.c :-) Any ideas about the broken capability bit?
It's possible we are adding the device before the capability - hence we ignore the device. Does the patch still work for you if you remove the hal_device_added_cb function?
Closing this bug report as no further information has been provided. Please feel free to reopen this bug if you can provide the information asked for. Thanks!