I have a touchscreen laptop that uses Ubuntu (HP Spectre X360). My screen has been replaced a couple of times and so there is a sometimes a problem with the touchscreen that makes it think that it is being touched randomly all over the screen. This makes it impossible to control anything and a reboot is required.
I know how to disable the touchscreen:
In the terminal I type xinput and I am presented with a list, e.g.:
I then find the number that corresponds to the ELAN Touchscreen (in this case 10) and then type:
xinput disable 10
Once the screen is going haywire however, it is too late to do this, as I can't type anything. So I want to automate this to be typed as soon as I boot my computer and disable the touchscreen automatically every time. But sometimes the number is not 10, it is sometimes 9.
I suppose I need some simple bash screen that inputs xinput but then finds the number that corresponds to the touchscreen and inputs xinput disable #.
Could anyone help me with that please?
12 Answers
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 1 To permanently disable the touchscreen input, here is another method:
Edit the file
/usr/share/X11/xorg.conf.d/10-evdev.confFind the entry for the ELAN Touchscreen
In "Driver" section, Change "evdev" to "libinput" so it would look like this:
Driver "libinput"If you find in the file an entry for "Touchscreen catchall", add to it the line:
Option "Ignore" "on"Another possibility is if you find this line:
MatchIsTouchscreen "on", then change it toMatchIsTouchscreen "off".Save the file and reboot.
Another method uses the command:
xinput --set-prop 'name of touchpad device' 'Device Enabled' 0 16