Saturday, 4 May 2013

Changing mouse settings from command line

Reactions: 
 To configure mouse settings from command line we can use an utility called "xinput". The manual for xinput defines it as a utility to list available input devices, query information about a device and change input device settings. i.e. xinput can be used to configure a variety of input devices like mouse, keyboard etc...
List Connected Devices
 On a GNOME 3.x desktop we can open command launcher (Alt+F2) and then use the command "gnome-terminal" to open terminal.
 To list all the devices connected to a machine we can run the following command in terminal xinput --list. In the following screenshot you can find that an optical mouse is connected to the machine and assigned a "device id 8".
List input Devices
Enable and Disable the device
 Sometimes we don't want mouse movement to bring up a machine from sleep. To disable the input device(mouse), we find the device id by listing all devices as shown above. After finding the device id of the mouse (8) we can run the following command in terminal to disable the mouse xinput --disable 8. Similarly to enable mouse again we can run the command xinput --enable 8. To make things more convenient we can set keyboard shortcuts for these commands as shown below
Keyboard shortcut disable enable mouse
Switch mouse buttons from right handed to left handed
 I for one use, "left handed" mouse settings . I find that on some "light weight" desktops, GUI based mouse settings are often not available which makes changing mouse settings a hassle. xinput comes to the rescue in these cases. To get the default mouse button mapping the following command can be used :- xinput get-button-map 8. To change the default mapping from right to left you can use the command xinput set-button-map 8 3 2 1. The following screenshot shows the demo.
Change Mouse mapping
 The above setting made through terminal will last only for one login session but, we can "apply" this setting every time we login by plugging the relevant command into the ~/.profile file in "home" directory as shown below.
.profile file xinput

1 comment:

  1. thank you for sharing it with us. this is very helpful post. Beefjerky.com Free Delivery

    ReplyDelete

LinkWithin

Related Posts Plugin for WordPress, Blogger...