1

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.:

enter image description here

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?

user1551817
  • 175
  • 2
  • 9
  • 29

2 Answers2

4

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
  • I'm in the folder `/etc/X11/xinit/` but there is no `xinitrc.d` folder. There is a file called `xinitrc` however. Should I create a `xinitrc.d` folder? – user1551817 Aug 06 '20 at 13:27
0

To permanently disable the touchscreen input, here is another method:

  • Edit the file /usr/share/X11/xorg.conf.d/10-evdev.conf

  • Find 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 to MatchIsTouchscreen "off".

  • Save the file and reboot.


Another method uses the command:

xinput --set-prop 'name of touchpad device' 'Device Enabled' 0
harrymc
  • 455,459
  • 31
  • 526
  • 924
  • For me, there was no ELAN Touchscreen, but there was the identifier: evdev touchscreen catchall. So I did as you suggested but the Touchscreen still worked when I rebooted unfortunately. – user1551817 Aug 06 '20 at 13:36
  • I have added more. – harrymc Aug 06 '20 at 18:19
  • I have just added Option "Ignore" "on" and changed to MatchIsTouchscreen "off" and now when I log in, neither my mouse or my keyboard work (once I log in) and so I am unable to undo what I did. Please advise asap as I am no longer able use my machine. – user1551817 Aug 09 '20 at 12:59
  • It might have been added at the wrong location. You might need to use a live boot to undo. – harrymc Aug 09 '20 at 13:27
  • Please see https://superuser.com/questions/1576422/mouse-and-keyboard-disabled-accidentally for a screenshot of what I changed the values to. – user1551817 Aug 09 '20 at 13:30
  • It might have been enough to do `MatchIsTouchscreen`. – harrymc Aug 09 '20 at 13:48
  • The keyboard and mouse work before I enter the password and log into my account. Is there no way I can fix this without a live boot? I don't have a boot data stick currently. – user1551817 Aug 09 '20 at 13:55
  • You might be able to edit the file in the browser. See for example [How to Edit Source Files Directly in Chrome](https://www.sitepoint.com/edit-source-files-in-chrome/) that uses Developer Tools to load, edit and save the file. – harrymc Aug 09 '20 at 13:55
  • I can't do it this way unfortunately. I guess I will have to wait until I can get a live boot data stick. Will I be able to plug a USB keyboard in and use that? – user1551817 Aug 09 '20 at 14:24
  • No reason that this wouldn't work. – harrymc Aug 09 '20 at 14:43
  • I have to navigate to the file using the touchscreen and it's almost impossible to do it with the touchscreen only partially working. – user1551817 Aug 09 '20 at 15:19
  • Okay I managed to navigate to usr/share/X11/xorg.conf.d/ but there is no 10-evdev.conf file available to select. So you cannot access it this way. – user1551817 Aug 09 '20 at 17:35
  • Don't you remember which file you updated? – harrymc Aug 09 '20 at 19:14
  • Yes. I have said above, it was 10-evdev.conf – user1551817 Aug 09 '20 at 20:15
  • Anyway, I have managed to get my mouse and keyboard working again - I have posted my solution on https://superuser.com/questions/1576422/mouse-and-keyboard-disabled-accidentally. I still have no solution for the touchscreen, but I think it is safer just to leave it alone. – user1551817 Aug 09 '20 at 20:17
  • Now that you have a way of undoing it, why not experiment. – harrymc Aug 09 '20 at 20:19