How to make xinput settings persist after devices are unplugged, replugged, and after shutdown, restart, etc?
I successfully followed the answer to this question to set different sensitivities for my touchpad and my USB mouse. Only problem is, once you unplug and replug the device or shutdown, restart etc., the settings reset.
Solution 1:
According to How to configure the TrackPoint (from ThinkWiki), the method for changing the settings on a per-user basis is by using the .xsessionrc
file, simply put all your xinput commands into that file and you should have your settings on boot.
The settings should be remembered after you unplug and replug the same device. But if they're not then we have a bug to report. I looked into all the events that happen when input devices are detected and I don't mind telling you that it's a real mess. If you need to go to a plan B then try adding the options into x.conf.d
as shown in the above website.
Solution 2:
I know this is a bit old, but in Ubuntu 14.04 I couldn't find a .xsessionrc
or x.conf.d
file, so I had to use xinput from the terminal. This is how you do it:
-
Check the name of your device:
xinput list
-
See available options for your device:
xinput list-props "Your Device Name"
-
Edit settings (to make settings consistent after reboot/shutdown just add this command to Startup Applications):
xinput set-prop "Your Device Name" "Option Name" "Value"
Here is an example command I used to activate locked drags in my touchpad:
xinput set-prop "SynPS/2 Synaptics TouchPad" "Synaptics Locked Drags" 1
To activate/change another option just look for it in your device available options and play with them until you get the desired result.
You now know which commands resolve your problems. They may be more than one. Your next job is to add these commands to 'Startup Applications'. To do so:
Open 'Startup Applications'.
Click 'Add' and in the command field paste the desired command. Click 'Add'. You have added the first command.
Add the other commands too in similar fashion (if you have more than one command). You are done. Next time you restart your computer, Ubuntu will automatically run these commands which will fix your mouse issues.
Solution 3:
I've had to put it in /etc/X11/xorg.conf.d/50-mouse-map.conf
(and reboot) to be permanent not only over reboots but also over suspend/resume.
#instead of: xinput set-button-map "2.4G Wireless Optical Mouse" 1 2 3 4 5 6 7 0
Section "InputClass"
Identifier "2.4G Wireless Optical Mouse"
Option "ButtonMapping" "1 2 3 4 5 6 7 0 0 10 11 12 13 14 15 16"
EndSection
(if I put it just in .xsession
or similar it would get executed on reboot / relogin, but would still reset to defaults after suspend/resume)
Solution 4:
Use the Startup Applications program.
Type in the terminal command and use "
to separate the values.
e.g.:
xinput set-button-map "12" "1" "1" "3"
Save and it works.