After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 635486 - Allow custom command to run on input device hotplug/removal
Allow custom command to run on input device hotplug/removal
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: mouse
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-settings-daemon-maint
gnome-settings-daemon-maint
: 598820 632463 638973 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2010-11-22 04:55 UTC by Peter Hutterer
Modified: 2011-03-21 14:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
0001-mouse-add-custom-hotplug-command.patch (6.54 KB, patch)
2010-11-22 04:55 UTC, Peter Hutterer
needs-work Details | Review
0001-Add-inputdevices-plugin-for-custom-hotplug-command.patch (30.36 KB, patch)
2011-03-21 06:52 UTC, Peter Hutterer
none Details | Review
common: Launch a custom script on input devices (8.31 KB, patch)
2011-03-21 09:45 UTC, Bastien Nocera
committed Details | Review

Description Peter Hutterer 2010-11-22 04:55:14 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.
Comment 1 Bastien Nocera 2010-11-26 14:07:27 UTC
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.
Comment 2 Peter Hutterer 2010-11-28 09:57:13 UTC
(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.
Comment 3 Peter Hutterer 2010-12-09 00:54:08 UTC
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 :)
Comment 4 Julien Cristau 2010-12-09 21:10:48 UTC
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?
Comment 5 Peter Hutterer 2010-12-09 21:52:01 UTC
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.
Comment 6 Julien Cristau 2010-12-09 22:00:01 UTC
(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.
Comment 7 Peter Hutterer 2010-12-09 22:10:46 UTC
oh, right. of course. makes sense, I'll add that in the next version.
Comment 8 Bastien Nocera 2011-02-19 03:58:24 UTC
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.
Comment 9 Peter Hutterer 2011-03-21 06:52:56 UTC
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?
Comment 10 Peter Hutterer 2011-03-21 06:58:17 UTC
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)
Comment 11 Bastien Nocera 2011-03-21 09:45:32 UTC
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.
Comment 12 Rodrigo Moya 2011-03-21 10:15:49 UTC
Review of attachment 183920 [details] [review]:

Looks good
Comment 13 Bastien Nocera 2011-03-21 10:21:16 UTC
Comment on attachment 183920 [details] [review]
common: Launch a custom script on input devices

Pushed as 2ec0fbd38cd9d787fc3ad003f462c537ea795890
Comment 14 André Klapper 2011-03-21 10:38:38 UTC
Meh, this broke the string freeze.
How important is it to fix this (does not have a GNOME3 target flag)?
Comment 15 Bastien Nocera 2011-03-21 10:57:42 UTC
(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.
Comment 16 Bastien Nocera 2011-03-21 14:08:02 UTC
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
Comment 17 Bastien Nocera 2011-03-21 14:14:42 UTC
*** Bug 598820 has been marked as a duplicate of this bug. ***
Comment 18 Bastien Nocera 2011-03-21 14:16:22 UTC
*** Bug 632463 has been marked as a duplicate of this bug. ***
Comment 19 Bastien Nocera 2011-03-21 14:16:37 UTC
*** Bug 638973 has been marked as a duplicate of this bug. ***