GNOME Bugzilla – Bug 635486
Allow custom command to run on input device hotplug/removal
Last modified: 2011-03-21 14:16:37 UTC
Created attachment 175004 [details] [review] 0001-mouse-add-custom-hotplug-command.patch from the commit message: -- snip -- A number of users require input configurations that go beyond what the gnome-control-center and gnome-settings-daemon offer. Some of these configurations are readily accessible through various commandline interfaces (synclient, xinput, xsetwacom, etc.) but are too uncommon to justify full inclusion into g-s-d and/or g-c-c. The attached patch adds a new key "hotplug-command" that lets the user specify a custom script to be executed whenever devices are added or removed. The script is called with two arguments: path/to/custom/command <added|removed|present> <device name> The first argument specifies if the device was just added or removed or is already present at g-s-d startup time. The device name is the name as provided by XInput. The custom command is called for all slave devices (incl. floating ones) but not for master devices. The callee is responsible for identifying the device if there are multiple devices with identifal names. Note: the custom command is called after g-s-d applies the device settings and may thus overwrite settings configured through g-s-d. -- snip -- There's an argument to be made that the key is better in .peripherals directly instead of in .mouse. Would be easy enough to change, but right now the mouse-manager has all the infrastructure in place already (directory watch, etc.), so integration was easier.
Review of attachment 175004 [details] [review]: The code looks fine, but I still don't see: - why is it implemented in the mouse plugin instead of its own plugin (if it's really required) - what the actual use cases are (would we be able to punt bug like https://bugzilla.gnome.org/show_bug.cgi?id=598820 ::: plugins/mouse/gsd-mouse-manager.c @@ +399,3 @@ + + argv[0] = cmd; + argv[1] = g_strdup_printf ("%s", command); argv[1] = command; and remove the g_free below.
(In reply to comment #1) > - why is it implemented in the mouse plugin instead of its own plugin (if it's > really required) because I am lazy and the infrastructure was already there :) if you think it's better kept separate, then I can do that but as proof-of-concept it was just simpler like this. I don't mind either way, I realise this isn't a mouse-specific setting > - what the actual use cases are (would we be able to punt bug like > https://bugzilla.gnome.org/show_bug.cgi?id=598820 yes, touchpad configurations that we don't cover are I think the biggest potential user group (corner tapping or circular scrolling are two examples here) and of course the multitude of wacom users that require configurations outside of what we have now.
just to be clear, I'm waiting for a "yeah, we'd be willing to commit this" before I start re-doing the patch. Just in case you are waiting for me :)
Wouldn't it be better to have the device id instead of (or in addition to) the name, to be able to discriminate devices with the same name?
the device ID would be trivial enough to add, though given that device ID's aren't constant I'm not sure whether it would be of any use. even just logging out and back in doesn't guarantee the IDs stay the same, so any configuration based on device IDs is prone to errors.
(In reply to comment #5) > the device ID would be trivial enough to add, though given that device ID's > aren't constant I'm not sure whether it would be of any use. even just logging > out and back in doesn't guarantee the IDs stay the same, so any configuration > based on device IDs is prone to errors. I was thinking that the device id would allow the command to query more information about the device from XI, or pass it to xinput.
oh, right. of course. makes sense, I'll add that in the next version.
So, I've thought about it, and I have a couple of requests: - this should be a separate plugin (see the a11y-settings plugin that was recently added, it's basically the dummy plugin, with a bunch of sed commands over it) - the plugin would be disabled by default - there would be a path to a script in the default configuration (say, under g_get_user_data_dir()/gnome-settings-daemon/input-device.sh). and finally, I'd like a proof-of-concept for bug 598820. If really needed for bug 598820, I'd accept a patch against the mouse plugin if you had to use the return value of the script to say that you don't want gnome-settings-daemon to apply settings for example.
Created attachment 183913 [details] [review] 0001-Add-inputdevices-plugin-for-custom-hotplug-command.patch Moved into a separate plugin called "inputdevices". Better name suggestions welcome ;) new key is org.gnome.settings-daemon.peripherals.inputdevices hotplug-command rest of the code is mostly identical. The format has changed a little bit, arguments for the script are now path/to/script -t [added|removed|present] device name to allow for getopt parsing and later addition of new parameters. Things missing: * I don't know how to get the device ID from Gdk * I don't know how to ensure the script is called last. At the moment I think it races with the mouse plugin. Maybe reducing the startup priority further ensures this? * How do I set the default value to g_user_data_dir()/blah blah?
A proof-of-concept for bug 598820 would look like this (added to the end of the example script in attachment 183913 [details] [review]): if [ "$device" = "SynPS/2 Synaptics TouchPad" ]; then xinput set-prop "$device" "Synaptics Tap Action" 0 0 0 0 1 2 3 fi (to set 1/2/3 finger tapping to LMR instead of LRM)
Created attachment 183920 [details] [review] common: Launch a custom script on input devices A number of users require input configurations that go beyond what the gnome-control-center and gnome-settings-daemon offer. Some of these configurations are readily accessible through various commandline interfaces (synclient, xinput, xsetwacom, etc.) but are too uncommon to justify full inclusion into g-s-d and/or g-c-c. This patch adds a new key org.gnome.settings-daemon.peripherals.input-devices hotplug-command that lets the user specify a custom script to be executed whenever devices are added or removed. The script is called with three arguments: path/to/custom/command -t [added|removed|present] -i <device ID> <device name> The first argument specifies if the device was just added or removed or is already present at g-s-d startup time. The device name is the name as provided by XInput. The custom command is called for all slave devices (incl. floating ones) but not for master devices. Note that the functionality is not currently called for any input devices.
Review of attachment 183920 [details] [review]: Looks good
Comment on attachment 183920 [details] [review] common: Launch a custom script on input devices Pushed as 2ec0fbd38cd9d787fc3ad003f462c537ea795890
Meh, this broke the string freeze. How important is it to fix this (does not have a GNOME3 target flag)?
(In reply to comment #14) > Meh, this broke the string freeze. It's adding new strings to the gschemas, which the translators know isn't a priority (or even necessary). > How important is it to fix this (does not have a GNOME3 target flag)? Important enough that Peter and I worked on it to get it integrated before GNOME 3.0.
commit 6751cb744ffd89ad15ce7b5e7e6f8bfef4ffbbbd Author: Bastien Nocera <hadess@hadess.net> Date: Mon Mar 21 14:05:12 2011 +0000 mouse: Hook up input device customisation script With blacklist support. https://bugzilla.gnome.org/show_bug.cgi?id=635486
*** Bug 598820 has been marked as a duplicate of this bug. ***
*** Bug 632463 has been marked as a duplicate of this bug. ***
*** Bug 638973 has been marked as a duplicate of this bug. ***