2

I have an 5 year old laptop and I think the touchscreen is getting glitchy because my cursor is sometimes flickering and windows suddenly move and whatnot like my laptop is possessed. It started happening in Ubuntu 20.04 right before I did a completely fresh install of Ubuntu 22.04 where the problem persisted, so I don't think the OS is the culprit; I'm pretty sure the touchscreen.

I've tried

xinput disable 5

but I get

WARNING: running xinput against an Xwayland server. See the xinput man page for details.

and it doesn't disable the touchscreen.

I tried:

modprobe -r hid_multitouch

But that only disabled part of the touchpad (not the touchscreen) functionality.

So, what's the right way to disable the touchscreen on a fresh install of Ubuntu 22.04 (Wayland)? Thanks.

chimeraha
  • 505
  • 6
  • 13
  • You can probably disable it in your BIOS. – heynnema May 30 '22 at 13:57
  • @heynnema There are limited options and no options for disabling inputs in my BIOS. – chimeraha May 30 '22 at 19:40
  • Click at the top right corner, select Settings -- Mouse and Touchpad and turn off the touchpad. If it does not work, switch from Wayland to Xorg. – sudodus May 30 '22 at 19:48
  • 1
    @sudodus The issue is with the touchscreen, not the touchpad, and there are no settings for the touchscreen. Thanks for the suggestion about switching to Xorg; I may have to do that eventually as a last resort. But until then it would be great to find a solution with Wayland. – chimeraha May 31 '22 at 20:21

3 Answers3

3

I followed this thread and created some scripts that work for a fresh install of ubuntu 22.04.

I couldn't figure out how to get awk's match function to work, so I just used code from @meuh and @JinnKo to create a non-awk version that disables/toggles multiple devices given a keyword.

First, make sure evtest is installed:

sudo apt install evtest

I have two files, one that toggles the touchscreen on and off, and one that always disables it when booting up.

Toggle Touchscreen:

#!/bin/bash
# This toggles my touchscreen
#search for "Touchscreen" or something like that in /proc/bus/input/devices to make sure you're disabling what you want to disable.

path_for_temp_files="/ANY_PATH_YOU_WANT_TO_STORE_SOME_PID_FILES/" regex='event([0-9]+)' DEVICE="Touchscreen"

if [ -r "${path_for_temp_files}touchscreen-evtest0.pid" ]; then kill_these_files=("${path_for_temp_files}"touchscreen-evtest*)

for i in "${kill_these_files[@]}"; do
    echo "kill" $(cat "${i}")
    sudo kill $(cat "${i}")
    sudo rm "${i}"
done  

else filename='/proc/bus/input/devices' inside=0 events=() while read line; do if [[ $line =~ $DEVICE ]]; then inside=1 fi

    if [[ $line =~ $regex ]]; then
        if [[ "$inside" -eq 1 ]]; then
            events+=("${BASH_REMATCH[1]}")
        fi
        inside=0
    fi
done < $filename

numevents=${#events[@]}

for (( i=0; i<${numevents}; i++ )); do
    sudo evtest --grab "/dev/input/event${events[$i]}" > /dev/null &
    pid=$!
    echo $pid > "${path_for_temp_files}touchscreen-evtest${i}.pid"
    echo "/dev/input/event${events[$i]} running on pid ${pid}"
done

fi

Disable Touchscreen to run at boot:

#!/bin/bash
# This disables my touchscreen
#search for "Touchscreen" or something like that in /proc/bus/input/devices to make sure you're disabling what you want to disable.

path_for_temp_files="/ANY_PATH_YOU_WANT_TO_STORE_SOME_PID_FILES/" regex='event([0-9]+)' DEVICE="Touchscreen"

if [ -r "${path_for_temp_files}touchscreen-evtest0.pid" ]; then kill_these_files=("${path_for_temp_files}"touchscreen-evtest*)

for i in "${kill_these_files[@]}"; do
    echo "kill" $(cat "${i}")
    sudo kill $(cat "${i}")
    sudo rm "${i}"
done  

fi

filename='/proc/bus/input/devices' inside=0 events=() while read line; do if [[ $line =~ $DEVICE ]]; then inside=1 fi

if [[ $line =~ $regex ]]; then
    if [[ "$inside" -eq 1 ]]; then
        events+=("${BASH_REMATCH[1]}")
    fi
    inside=0
fi

done < $filename

numevents=${#events[@]}

for (( i=0; i<${numevents}; i++ )); do sudo evtest --grab "/dev/input/event${events[$i]}" > /dev/null & pid=$! echo $pid > "${path_for_temp_files}touchscreen-evtest${i}.pid" echo "/dev/input/event${events[$i]} running on pid ${pid}" done

Then I followed this answer to run as root at startup

chimeraha
  • 505
  • 6
  • 13
  • Thanks for the scripts, I had troubles finding something that works! Only suggestion, the run-at-startup guide is old (though working), it is probably better to use some more up-to-date method such as systemd or crontab: https://www.linuxuprising.com/2021/12/how-to-run-command-or-script-as-root-on.html – poomerang Dec 12 '22 at 08:58
  • Brilliant! Thanks for sharing this. I have an X1 Carbon with a malfunctioning touch screen and this worked perfectly!. THANKS! – Rick Rainey Feb 23 '23 at 19:23
  • OMG, thank you! Finally a solution that works (on a Lenovo Flex). I've tried so many things before and none of them worked. – joinijo Mar 30 '23 at 10:47
  • Thanks a mil! Worked on Asus UX360CA with a glitchy touchscreen running Ubuntu 22.04. For me the device name didn't contain the word "touch", and this is where evtest came in very handy to help to find out that the device name was smth like "FTSC". – gevra Jan 06 '24 at 18:32
0

Although this is quite old I wanted to share that I used the accepted answer to create a little helper script for myself. The script dis- and enables Touch automatically based on the proximity of the stylus.

Currently I use used with Ubuntu 22.04 with wayland on my ThinkPad Yoga L13ut probably it is quite easy to adapt to other systems as well.

Ditschi
  • 31
-1

I found none of the above worked (there is no Touchscreen device). So I switched from Wayland to X11, then ran xinput disable 11, 11 being what appeared to be a pointing device (xinput list):

⎜ ELAN2514:00 04F3:2AF2 id=11 [slave pointer (2)]

⎜ SYNA32A0:00 06CB:CE14 Mouse id=13 [slave pointer (2)]

⎜ SYNA32A0:00 06CB:CE14 Touchpad id=14 [slave pointer (2)]

ELAN and SYNAptics are two pointer chip types. I guessed the ELAN was the touchscreen.

To switch to X11, when you type in your login name, a gear appears in the bottom right of the login page. Click on that and select X11.