1/ Short version : (checked on Ubuntu 16.04)
Update .xinputrc file in your $HOME directory and put your xinput commands inside (one by line). It will be read each time you'll open your session.
If it does not exists, create it : (should have been generated by im-config)
Mine :
# im-config(8) generated on Wed, 15 Feb 2017 19:29:43 +0100
run_im ibus
# im-config signature: 90bece1e5f840b27085989abd900276a -
#BYME# Put your xinput commands here
#BYME#With DRI2 : Device Accel Constant Deceleration (267)
xinput --set-prop 11 267 2
#BYME#With DRI3 : Device Accel Constant Deceleration (264)
xinput --set-prop 11 264 2
This .xinputrc works for both cases (if DRI3 is enabled or not)
By the way, I'm using multiple screens (mixing 4K and old fashion 16:9 screens) and I feel comfortable having only set Device Accel Constant Deceleration
to 2
. Feel free to change this (or other) value.
2/ Wrong way to do it :
(DO NOT) add it to your .bashrc or another profile specific file (which can be read many more times and can lead to misinterpretation of what mouse behaviour is actually really applied)
3/ Long version : (working on distributions supporting xinput commands)
To determine which options you should use :
$ xinput --list --short
On my Ubuntu host (I'm using a KVM to switch between my computers), it returns :
Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ No brand Combo Free KVM id=11 [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)]
↳ No brand Combo Free KVM id=10 [slave keyboard (3)]
So instead of messing with strings (and making errors while typing it), I prefer to use (short) numeric identifiers (knowing now how to find them and their meanings).
In my case, my mouse is under Virtual core pointer
, identified as No brand Combo Free KVM
with numeric identifier 11
. As explained previously, I'm now going to use this numeric identifier instead of the corresponding string but you can do as you want (both work).
To know which properties / capabilities are available with my mouse, I have to type : (adapt this command with the result of the previous one, your own identifier should be different)
$ xinput --list-props 11
Device 'No brand Combo Free KVM':
Device Enabled (136): 1
Coordinate Transformation Matrix (138): 1.000000, 0.000000, 0.000000, 0.000000,
1.000000, 0.000000, 0.000000, 0.000000, 1.000000
Device Accel Profile (266): 0
Device Accel Constant Deceleration (267): 1.000000
Device Accel Adaptive Deceleration (268): 1.000000
Device Accel Velocity Scaling (269): 10.000000
Device Product ID (257): 4309, 20480
Device Node (258): "/dev/input/event16"
Evdev Axis Inversion (270): 0, 0
Evdev Axes Swap (272): 0
Axis Labels (273): "Rel X" (146), "Rel Y" (147), "Rel Horiz Wheel" (264), "
Rel Vert Wheel" (265)
Button Labels (274): "Button Left" (139), "Button Middle" (140), "Button Righ
t" (141), "Button Wheel Up" (142), "Button Wheel Down" (143), "Button Horiz Wheel Left"
(144), "Button Horiz Wheel Right" (145), "Button Side" (262), "Button Extra" (263), "But
ton Unknown" (260), "Button Unknown" (260), "Button Unknown" (260), "Button Unknown" (26
0)
Evdev Scrolling Distance (275): 1, 1, 1
Evdev Middle Button Emulation (276): 0
Evdev Middle Button Timeout (277): 50
Evdev Third Button Emulation (278): 0
Evdev Third Button Emulation Timeout (279): 1000
Evdev Third Button Emulation Button (280): 3
Evdev Third Button Emulation Threshold (281): 20
Evdev Wheel Emulation (282): 0
Evdev Wheel Emulation Axes (283): 0, 0, 4, 5
Evdev Wheel Emulation Inertia (284): 10
Evdev Wheel Emulation Timeout (285): 200
Evdev Wheel Emulation Button (286): 4
Evdev Drag Lock Buttons (287): 0
This is how we can identify which properties should be changed !
Accel Constant Deceleration
(numeric identifier : 267
) is doing the job quite well for me. Feel free to "play" with other properties to find the right behaviour for your own mouse.
So, that's why I've added the next line to my .xinputrc, changing value from 1.000000
to 2
(specifying a float is not required) because augmenting deceleration leads to slowing down mouse speed:
xinput --set-prop 11 267 2
4/ Warning : this identifiers can change if you have activated DRI3
DRI2 only, by default, under Ubuntu 16.04 (while it can lead to problems, like with last versions of Chrome, requiring DRI3 to support smooth multiwindow)
If you have enabled DRI3, identifiers should now be :
Device 'No brand Combo Free KVM':
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 (263): 0
Device Accel Constant Deceleration (264): 1.000000
Device Accel Adaptive Deceleration (265): 1.000000
Device Accel Velocity Scaling (266): 10.000000
Device Product ID (254): 4309, 20480
Device Node (255): "/dev/input/event9"
Evdev Axis Inversion (267): 0, 0
Evdev Axes Swap (269): 0
Axis Labels (270): "Rel X" (143), "Rel Y" (144), "Rel Horiz Wheel" (261), "
Rel Vert Wheel" (262)
Button Labels (271): "Button Left" (136), "Button Middle" (137), "Button Righ
t" (138), "Button Wheel Up" (139), "Button Wheel Down" (140), "Button Horiz Wheel Left"
(141), "Button Horiz Wheel Right" (142), "Button Side" (259), "Button Extra" (260), "But
ton Unknown" (257), "Button Unknown" (257), "Button Unknown" (257), "Button Unknown" (25
7)
Evdev Scrolling Distance (272): 1, 1, 1
Evdev Middle Button Emulation (273): 0
Evdev Middle Button Timeout (274): 50
Evdev Third Button Emulation (275): 0
Evdev Third Button Emulation Timeout (276): 1000
Evdev Third Button Emulation Button (277): 3
Evdev Third Button Emulation Threshold (278): 20
Evdev Wheel Emulation (279): 0
Evdev Wheel Emulation Axes (280): 0, 0, 4, 5
Evdev Wheel Emulation Inertia (281): 10
Evdev Wheel Emulation Timeout (282): 200
Evdev Wheel Emulation Button (283): 4
Evdev Drag Lock Buttons (284): 0
Accel Constant Deceleration
is now idenfified by 264
. That's why I've also added (having same behaviour no matter if DRI3 is enabled or not) in my .xinputrc :
xinput --set-prop 11 264 2
Hope it will help you.