I'm trying to slow down my Magic Mouse sensibility using a xinput
command automatically when my mouse is connected to my computer.
I managed to create a file under rules.d
, that calls a shell script. The problem is that it works well for all scripts except the xinput
command because the rule launches the script before that the mouse is listed between other input devices and so xinput
command fails to find it.
So, my question is if there is a way to run the command I need only after that mouse is detected as input device or if there are other solutions to my problem.
From terminal, before the mouse connects by BT:
$ hcitool inq
Inquiring ...
00:1E:52:EE:0C:1B clock offset: 0x33fb class: 0x3a0104
84:38:35:31:CC:6B clock offset: 0x1353 class: 0x002580
$ hcitool scan
Scanning ...
84:38:35:31:CC:6B Mouse of Elios
00:1E:52:EE:0C:1B Elios
After the mouse connects by BT I get:
$ hcitool info 84:38:35:31:CC:6B
Requesting information ...
BD Address: 84:38:35:31:CC:6B
Device Name: Mouse of Elios
LMP Version: 2.0 (0x3) LMP Subversion: 0x31c
Manufacturer: Apple, Inc. (76)
Features: 0xbd 0x02 0x04 0x38 0x08 0x00 0x00 0x00
<3-slot packets> <encryption> <slot offset> <timing accuracy>
<role switch> <sniff mode> <RSSI> <power control>
<enhanced iscan> <interlaced iscan> <interlaced pscan>
<AFH cap. slave>
This is my udev rule placed in /etc/udev/rules.d:
SUBSYSTEMS=="input", ATTRS{name}=="Mouse of Elios", RUN+="/home/elios/Documents/FixMouse.sh"
This is my shell script /home/elios/Documents/FixMouse.sh
(edited thanks to Cbhihe answer):
#!/bin/sh
while [ ! "$(/usr/bin/hcitool info 84:38:35:31:CC:6B 2>&1 > /dev/null; echo $?)" ]; do
sleep 0.1
done
xinput --set-prop "Mouse of Elios" "Device Accel Constant Deceleration" 2.5
Other informations:
$ uname -a
Linux dalek 3.19.0-30-generic #34-Ubuntu SMP Fri Oct 2 22:08:41 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
$ xinput --list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ Mouse of Elios id=13 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Power Button id=8 [slave keyboard (3)]
↳ Sleep Button id=9 [slave keyboard (3)]
↳ Apple, Inc Apple Keyboard id=10 [slave keyboard (3)]
↳ Apple, Inc Apple Keyboard id=11 [slave keyboard (3)]
↳ FaceTime HD Camera (Built-in) id=12 [slave keyboard (3)]
$ xinput --list-props "Mouse of Elios"
Device 'Mouse of Elios':
Device Enabled (133): 1
Coordinate Transformation Matrix (135): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
Device Accel Profile (527): 0
Device Accel Constant Deceleration (528): 2.500000
Device Accel Adaptive Deceleration (529): 1.000000
Device Accel Velocity Scaling (530): 10.000000
Device Product ID (253): 1452, 781
Device Node (254): "/dev/input/event5"
Evdev Axis Inversion (531): 0, 0
Evdev Axes Swap (533): 0
Axis Labels (534): "Rel X" (143), "Rel Y" (144), "Rel Horiz Wheel" (517), "Rel Vert Wheel" (518)
Button Labels (535): "Button Left" (136), "Button Middle" (137), "Button Right" (138), "Button Wheel Up" (139), "Button Wheel Down" (140), "Button Horiz Wheel Left" (141), "Button Horiz Wheel Right" (142)
Evdev Scrolling Distance (536): 1, 1, 1
Evdev Middle Button Emulation (537): 0
Evdev Middle Button Timeout (538): 50
Evdev Third Button Emulation (539): 0
Evdev Third Button Emulation Timeout (540): 1000
Evdev Third Button Emulation Button (541): 3
Evdev Third Button Emulation Threshold (542): 20
Evdev Wheel Emulation (543): 0
Evdev Wheel Emulation Axes (544): 0, 0, 4, 5
Evdev Wheel Emulation Inertia (545): 10
Evdev Wheel Emulation Timeout (546): 200
Evdev Wheel Emulation Button (547): 4
Evdev Drag Lock Buttons (548): 0
hcitool inq
in terminal ? How abouthcitool scan
? Please include your answer in your question by editing it. Notify me with @Cbhihe in a comment.$root/$name
. What is that supposed to actually do in your script ? As far as I can tell: nothing.