Blog | Emin Mastizadahttps://mastizada.com/blog/2024-03-29T05:28:47.397757+00:00BlogDisable Touchscreen in Gnu/Linux2018-10-19T09:49:31+00:002024-03-29T05:28:47.397757+00:00Emin Mastizadahttps://mastizada.com/blog/author/mastizada/https://mastizada.com/blog/disable-touchscreen-in-gnulinux/<p>Some of new laptops have touchscreen functionality. It is fancy, but practically it is useless. Mostly, you touch it by mistake and it uses some battery.</p>
<p>Recently I cracked my laptop's screen, it is a small crack that doesn't distract me but somehow it is making some random touches. I was searching for ways to disable touchscreen and most of them wasn't working and touchscreen was enabled again after reboot or sleep.</p>
<p>You can temporarily disable your touchscreen (or any other input device) using <code>xinput</code> tool. Use <code>xinput --list</code> to get the list of your input devices and use their id to disable any of them: <code>xinput disable <id number></code>.</p>
<p>I added this command to the autostart to disable at boot:</p>
<p><code>xinput --list | awk '/Atmel Atmel maXTouch Digitizer/ {print $7}' | awk '{split($0,a,"="); print a[2]}' | xargs xinput disable</code></p>
<p>It works fine, it finds the id number of the touchscreen device (it can change at boot) using its name (Atmel Atmel maXTouch Digitizer - from xinput list) and disables it. The only problem is that, touchscreen becomes enabled again after sleep. Also, for some unknown reason, it is not working at every reboot.</p>
<p>There is also another way, disable the module for the touchscreen device, but I hate that way as missing modules are annoying.</p>
<h2>X11:</h2>
<p>My final solution that worked well was to create a configuration file in X11 and add a general touchscreen disabling setting to it. For example, I have created <code>/etc/X11/xorg.conf.d/94-no-touchscreen.conf</code> file and added this content to it:</p>
<p><code>Section "InputClass"</code><br/><code> Identifier "Touchscreen catchall"</code><br/><code> MatchIsTouchscreen "on"</code><br/><code> Option "Ignore" "on"</code><br/><code>EndSection</code></p>
<p>That works both on reboots and on waking from the sleep mode.</p>
<h2>Wayland:</h2>
<p>Find vendor and product id of the device using <code>cat /proc/bus/input/devices</code> - In the output try to find your touchscreen device and use its <code>Vendor=<VendorID> Product=<ProductID></code> value to create an <code>udev</code> rule. Create a file <code>/etc/udev/rules.d/94-no-touchscreen.conf</code> with the following content (replace <code>VendorID</code> and <code>ProductID</code> with according values):</p>
<p><code>SUBSYSTEM=="usb", ATTRS{idVendor}=="VendorID", ATTRS{idProduct}=="ProductID", ATTR{authorized}="0"</code></p>
<p><em>Note: To find more about your touchscreen device, you can use <code>udevadm</code> tool. Sysfs flag of input devices (after vendor & product id and name lines) will give a hint about the path of the device, use <code>udevadm info /<path under the /dev</code> to get detailed information for that device.</em></p>
<p>You can restart after that or reload rules: <code>udevadm control --reload-rules && udevadm trigger</code></p>
<p></p>
<h3>Sources:</h3>
<p>1. <a href="http://web.archive.org/web/20200930025850/https://askubuntu.com/questions/927022/how-can-i-disable-touchscreen-while-using-wayland/1011125#1011125" target="_blank">Answer by Dmitry in stackoverflow.</a></p>