{"id":52987,"date":"2020-01-01T21:51:41","date_gmt":"2020-01-02T05:51:41","guid":{"rendered":"https:\/\/linuxhint.com\/?p=52987"},"modified":"2021-07-11T18:00:03","modified_gmt":"2021-07-12T01:00:03","slug":"change_mouse_touchpad_settings_xinput_linux","status":"publish","type":"post","link":"https:\/\/linuxhint.com\/change_mouse_touchpad_settings_xinput_linux\/","title":{"rendered":"How to Change Mouse and Touchpad Settings Using Xinput in Linux"},"content":{"rendered":"<div id=\"wpbody\">\nMost Linux distributions ship with \u201clibinput\u201d library by default to handle input events on a system. It can process input events on both Wayland and X and can handle a variety of input devices including touchscreen displays and stylus pens.<\/p>\n<p>This article explains changing various options for an input device being handled by the libinput library. To check and configure available options, a command line tool called \u201cxinput\u201d will be used.<\/p>\n<p>Note that this guide works with X display server only. For Wayland, you have to rely on system settings provided by the distribution or use a centralized configuration utility like gsettings.<\/p>\n<h3>List Input Devices<\/h3>\n<p>Xinput comes pre-installed by default on Ubuntu. If for some reason it is not installed on your system, run the command below to install it:<\/p>\n<div class=\"codecolorer-container bash default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span><span class=\"kw2\">sudo<\/span> apt <span class=\"kw2\">install<\/span> xinput<\/div><\/div>\n<p>To list all built-in and external input devices connected to your system, run the command below:<\/p>\n<div class=\"codecolorer-container bash default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span>xinput <span class=\"re5\">--list<\/span><\/div><\/div>\n<p>You will see some output in terminal like this:<\/p>\n<p><a href=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2020\/01\/1-4.png\"><img decoding=\"async\" class=\"aligncenter size-large wp-image-52989\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2020\/01\/1-4-1024x654.png\" alt=\"\" width=\"810\" height=\"517\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2020\/01\/1-4-1024x654.png 1024w, https:\/\/linuxhint.com\/wp-content\/uploads\/2020\/01\/1-4-300x192.png 300w, https:\/\/linuxhint.com\/wp-content\/uploads\/2020\/01\/1-4-768x491.png 768w, https:\/\/linuxhint.com\/wp-content\/uploads\/2020\/01\/1-4-810x518.png 810w, https:\/\/linuxhint.com\/wp-content\/uploads\/2020\/01\/1-4.png 1078w\" sizes=\"(max-width: 810px) 100vw, 810px\" \/><\/a><\/p>\n<p>The entry under \u201cVirtual core pointer\u201d (highlighted by red arrows) is a wired USB mouse connected to my system. You will have to use exact name or id shown in the screenshot above to configure mouse or touchpad settings through the xinput command line tool.<\/p>\n<p>Note that in the screenshot above, xinput is showing properties of devices connected to my system. Device names and IDs will be different for your system depending on your hardware configuration and external devices connected via USB, Bluetooth, or wireless receivers.<\/p>\n<h3>View Properties of a Connected Device<\/h3>\n<p>To see current status and various options active for the device listed above, run a command in the following format:<\/p>\n<div class=\"codecolorer-container bash default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span>xinput <span class=\"re5\">--list-props<\/span> \u201c<span class=\"kw2\">id<\/span>\u201d<\/div><\/div>\n<p>For the Dell mouse listed above, the command would be:<\/p>\n<div class=\"codecolorer-container bash default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span>xinput <span class=\"re5\">--list-props<\/span> <span class=\"nu0\">8<\/span><\/div><\/div>\n<p>There is a limitation with using this command. IDs shown in the terminal output tend to change when you connect a listed device to a different port. As the IDs keep changing, there is always a chance of accidentally changing settings for a different device. To overcome this issue, it is better to use full device name as identifier instead of its id. So for the Dell mouse listed above, the better command would be:<\/p>\n<div class=\"codecolorer-container bash default\" style=\"overflow:auto;white-space:nowrap;width:700px;\"><div class=\"bash codecolorer\"><span class=\"co4\">$ <\/span>xinput <span class=\"re5\">--list-props<\/span> <span class=\"st0\">&quot;PixArt Dell MS116 USB Optical Mouse&quot;<\/span><\/div><\/div>\n<p>The area highlighted below in red rectangle shows current configuration for the device. You can only change options that are shown in the output. Depending on the capabilities of your device, some extra options may be listed while others can be omitted altogether.<\/p>\n<p><a href=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2020\/01\/2-4.png\"><img decoding=\"async\" class=\"aligncenter size-large wp-image-52990\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2020\/01\/2-4-1024x681.png\" alt=\"\" width=\"810\" height=\"539\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2020\/01\/2-4-1024x681.png 1024w, https:\/\/linuxhint.com\/wp-content\/uploads\/2020\/01\/2-4-300x199.png 300w, https:\/\/linuxhint.com\/wp-content\/uploads\/2020\/01\/2-4-768x510.png 768w, https:\/\/linuxhint.com\/wp-content\/uploads\/2020\/01\/2-4-810x538.png 810w, https:\/\/linuxhint.com\/wp-content\/uploads\/2020\/01\/2-4-1140x758.png 1140w, https:\/\/linuxhint.com\/wp-content\/uploads\/2020\/01\/2-4.png 1163w\" sizes=\"(max-width: 810px) 100vw, 810px\" \/><\/a><\/p>\n<h3>Change Properties of a Connected Device<\/h3>\n<p>Now that you know how to check the properties of a connected input device, settings for it can be easily changed using some simple commands.<\/p>\n<p>For instance, to enable or disable natural scrolling, you have to run commands in the following format:<\/p>\n<div class=\"codecolorer-container bash default\" style=\"overflow:auto;white-space:nowrap;width:700px;\"><div class=\"bash codecolorer\">$ xinput set-prop <span class=\"st0\">&quot;PixArt Dell MS116 USB Optical Mouse&quot;<\/span> <span class=\"nu0\">285<\/span> <span class=\"nu0\">0<\/span><br \/>\n$ xinput set-prop <span class=\"st0\">&quot;PixArt Dell MS116 USB Optical Mouse&quot;<\/span> <span class=\"nu0\">285<\/span> <span class=\"nu0\">1<\/span><\/div><\/div>\n<p>\u201c285\u201d is the id for natural scrolling, as shown in the screenshot above. \u201c0\u201d disables natural scrolling while \u201c1\u201d enables it. Once again, using IDs is not a reliable way to change these settings. A better approach is to use the full property identifier.<\/p>\n<div class=\"codecolorer-container bash default\" style=\"overflow:auto;white-space:nowrap;width:780px;\"><div class=\"bash codecolorer\">$ xinput set-prop <span class=\"st0\">&quot;PixArt Dell MS116 USB Optical Mouse&quot;<\/span> <br \/>\n<span class=\"st0\">&quot;libinput Natural Scrolling Enabled&quot;<\/span> <span class=\"nu0\">0<\/span><br \/>\n$ xinput set-prop <span class=\"st0\">&quot;PixArt Dell MS116 USB Optical Mouse&quot;<\/span><br \/>\n<span class=\"st0\">&quot;libinput Natural Scrolling Enabled&quot;<\/span> <span class=\"nu0\">1<\/span><\/div><\/div>\n<p>Note that you are not supposed to touch property identifiers having the word \u201cDefault\u201d in it. These are reference fallback values and any attempt to change them will result in xinput throwing an error.<\/p>\n<p>To know more about other options and those listed in the terminal output above, visit the following <u><a href=\"https:\/\/www.mankier.com\/4\/libinput#Supported_Properties\">page<\/a><\/u>.<\/p>\n<h3>Making the Changes Persistent<\/h3>\n<p>The method explained above changes settings for active session only. When you reboot the system, these changes will be gone. To make them persistent, two approaches can be used.<\/p>\n<p>The first method requires you to add these commands to startup applications. You can add as many entries as you want using a nice graphical interface. No root permissions are required to create these entries, plus changing them later is super easy.<\/p>\n<p>To add the command to startup applications, launch \u201cStartup Applications\u201d app from the application launcher. Click on \u201cAdd\u201d button to add an entry. Set a description and enter appropriate xinput command as per your needs. Make sure that checkbox is checked once you have saved the entry.<\/p>\n<p>That\u2019s it, the xinput command you have entered will run automatically on system startup. I have added a little bit of delay to the command to wait for the session to load properly. For reference, here is the command used below in the screenshot below:<\/p>\n<div class=\"codecolorer-container bash default\" style=\"overflow:auto;white-space:nowrap;width:700px;\"><div class=\"bash codecolorer\">$ <span class=\"kw2\">sleep<\/span> <span class=\"nu0\">3<\/span> <span class=\"sy0\">&amp;&amp;<\/span> xinput set-prop <span class=\"st0\">&quot;PixArt Dell MS116 USB Optical Mouse&quot;<\/span> <br \/>\n<span class=\"st0\">&quot;libinput Natural Scrolling Enabled&quot;<\/span> <span class=\"nu0\">1<\/span><\/div><\/div>\n<p><a href=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2020\/01\/3-4.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-52991\" src=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2020\/01\/3-4.png\" alt=\"\" width=\"686\" height=\"621\" srcset=\"https:\/\/linuxhint.com\/wp-content\/uploads\/2020\/01\/3-4.png 686w, https:\/\/linuxhint.com\/wp-content\/uploads\/2020\/01\/3-4-300x272.png 300w\" sizes=\"(max-width: 686px) 100vw, 686px\" \/><\/a><\/p>\n<p>The second method requires you to run some commands as root and edit a text file. The advantage of using this method is that you don\u2019t have to create separate entries for each option in a GUI and everything just resides in one text file, making it easier to share it between devices.<\/p>\n<p>Run the commands below to create required directory and the conf file:<\/p>\n<div class=\"codecolorer-container bash default\" style=\"overflow:auto;white-space:nowrap;width:680px;\"><div class=\"bash codecolorer\">$ <span class=\"kw2\">sudo<\/span> <span class=\"kw2\">mkdir<\/span> <span class=\"re5\">-p<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>X11<span class=\"sy0\">\/<\/span>xorg.conf.d<br \/>\n$ <span class=\"kw2\">sudo<\/span> <span class=\"kw2\">touch<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>X11<span class=\"sy0\">\/<\/span>xorg.conf.d<span class=\"sy0\">\/<\/span><span class=\"nu0\">99<\/span>-libinput.conf<\/div><\/div>\n<p>Notice the \u201c99\u201d part in the filename. It indicates the load order of the files that exist in \u201cxorg.conf.d\u201d folder. A file that has the highest number as prefix will be loaded last, overriding any options specified in previous files in case there are duplicates. By specifying \u201c99\u201d or any other number as a prefix, you can ensure that it is loaded after other files.<\/p>\n<p>Open \u201c99-libinput.conf\u201d file with root access in your favorite text editor. Enter the code snippet below after making necessary changes as per your requirements.<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:680px;\"><div class=\"text codecolorer\">Section &quot;InputClass&quot;<br \/>\nIdentifier &quot;Dell Mouse&quot;<br \/>\nMatchProduct &quot;PixArt Dell MS116 USB Optical Mouse&quot;<br \/>\nOption &quot;NaturalScrolling&quot; &quot;true&quot;<br \/>\nEndSection<\/div><\/div>\n<p>Where:<\/p>\n<ul>\n<li>Identifier &#8220;Dell Mouse&#8221; can be any name that you assign to the device to identify it (change as needed)<\/li>\n<li>MatchProduct &#8220;PixArt Dell MS116 USB Optical Mouse&#8221; is the exact device name you found in the \u201cxinput &#8211;list\u201d command used above (change as needed)<\/li>\n<li>Option &#8220;NaturalScrolling&#8221; &#8220;true&#8221; enables natural scrolling system wide (change as needed)<\/li>\n<\/ul>\n<p>By correctly specifying \u201cMatchProduct\u201d, you will be able to limit the configuration options to a specific device only. Changes made in the conf file will take effect when you reboot next time. You can add any number of options in the \u201cInputClass\u201d section. A list of various options that can be added to the file is available <u><a href=\"https:\/\/www.mankier.com\/4\/libinput#Configuration_Details\">here<\/a><\/u>.<\/p>\n<h3>Conclusion<\/h3>\n<p>The method explained above is especially useful when you want to use per device configuration rules. Default system settings interface in GNOME and KDE provide only some of the most commonly used options available for various input devices. To configure advanced options for an input device, you have no choice but to either use \u201cxinput\u201d or create a dedicated configuration file.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Most Linux distributions ship with \u201clibinput\u201d library by default to handle input events on a system. It can process input events on both Wayland and X and can handle a variety of input devices including touchscreen displays and stylus pens.  This article explains changing various options for an input device being handled by the libinput library. To check and configure available options, a command line tool called \u201cxinput\u201d will be used.<\/p>\n","protected":false},"author":73,"featured_media":52994,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2161],"tags":[2304],"class_list":["post-52987","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-commands","tag-mouse"],"_links":{"self":[{"href":"https:\/\/linuxhint.com\/wp-json\/wp\/v2\/posts\/52987","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxhint.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxhint.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxhint.com\/wp-json\/wp\/v2\/users\/73"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxhint.com\/wp-json\/wp\/v2\/comments?post=52987"}],"version-history":[{"count":0,"href":"https:\/\/linuxhint.com\/wp-json\/wp\/v2\/posts\/52987\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxhint.com\/wp-json\/wp\/v2\/media\/52994"}],"wp:attachment":[{"href":"https:\/\/linuxhint.com\/wp-json\/wp\/v2\/media?parent=52987"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxhint.com\/wp-json\/wp\/v2\/categories?post=52987"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxhint.com\/wp-json\/wp\/v2\/tags?post=52987"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}