Disable Touchscreen Automatically on Boot in Bash

Solution 1:

I'm going to improve this answer for you a little.

Create a file called for example disable-touchscreen.sh in the /etc/X11/xinit/xinitrc.d/ folder with the following content.

#!/bin/sh
[ -x /usr/bin/xinput ] && /usr/bin/xinput disable 'ELAN Touchscreen'

Make sure it is executable (chmod +x /etc/X11/xinit/xinitrc.d/disable-touchscreen.sh).

You can use it this way, quoting man xinput:

device can be the device name as a string or the XID of the device.

If your distribution doesn't contain the /etc/X11/xinit/xinitrc.d/ folder (Ubuntu most likely doesn't), then create it.

Also take a look into your home, if there is a file named .xinitrc, ensure it contains a block like

# run all system xinitrc shell scripts.
for file in /etc/X11/xinit/xinitrc.d/* ; do
        . $file
done