15

Since installing Ubuntu 22.04 I can't disable the touchpad in my settings or using the keyboard shortcut.

In the settings under Mouse & Touchpad I can enable/disable the touchpad by toggling the switch and it looks like it is working as expected but actually it has no effect: the touchpad is always enabled. This also happens when I use the keyboard shortcut (Fn+f9, on my my laptop).

However if I use xinput in a shell, I can actually turn the touchpad off using xinput -disable 13 and back on again using xinput -enable 13

It would be nice if anyone knows how to properly fix this. If not is there a script I can edit to include the above xinput commands when I press Fn+f9?

5
  • 2
    just go to System Settings and make a keyboard shortcut, add that command... or search for a setting that might turn it off gsettings list-recursively | grep touch.... I usually disable mine in bios; so I don't really ever deal with it or know which one applies on gnome. But on my machine running MATE, I saw org.mate.peripherals-touchpad touchpad-enabled true ...If you see something similar , try using gsettings set to set it to false ....Toggling that switch in settings, should be changing this(similar) value between "true" and false"...
    – WU-TANG
    May 12, 2022 at 2:49
  • Thanks that is useful May 12, 2022 at 10:23
  • additional info: on my system (also Ubuntu 22.04) the touchpad was not at 13 but at 15 which I checked by executing "xinput" without arguments. I then successfully disabled the touchpad with "xinput -disable 15"
    – Barden
    May 29, 2022 at 10:03
  • 1
    @PaulMackinlay - I had that same problem too. Can try sudo apt remove xserver-xorg-input-synaptics?
    – FedKad
    Jun 4, 2022 at 11:33
  • @FedKad - that fixed it properly. Thanks! Jun 5, 2022 at 14:03

7 Answers 7

11

I had that same problem too.

I was able to restore normal touchpad settings behavior (that is, controlling it at GNOME SettingsMouse & TouchpadTouchpad) by doing:

sudo apt remove xserver-xorg-input-synaptics

It seems that this package has some problems with disabling touchpad:

7

Based on WU-TANG's comment I have added a keyboard shortcut that executes this script so I can toggle the touchpad. It is a workaround so it doesn't fix the underlying issue:

#!/bin/bash
ID=$(echo `xinput list | grep Touchpad` | cut -d'=' -f 2 | cut -d' ' -f 1)
ENABLED=$(xinput --list-props $ID | grep Enabled | cut -d':' -f 2 | xargs)
if [[ $ENABLED == 1 ]]; then
  xinput -disable $ID
  echo Touchpad is disabled
else
  xinput -enable $ID
  echo Touchpad is enabled
fi

UPDATE - @FedKad answer is the proper solution - thanks for solving it for me!

4

How to enable/disable the touchpad/trackpad in Ubuntu 22.04 from the command-line, including automatically if an external mouse is plugged in

For anyone just looking for this, here's how.

Tested on Ubuntu 22.04 with the default Wayland display server as well as the X11 display server (I recommend X11--see why at the end of my answer here).

If using the new (and default, as of Ubuntu 22.04) Wayland display server rather than the X display server, xinput won't work to try to disable the touchpad or touchscreen. Instead, use gsettings. On Ubuntu 22.04 at least (I haven't tried it on earier vresions of Ubuntu), even with the X11 display server, gsettings works as well. Here is how:

# disable the touchpad
gsettings set org.gnome.desktop.peripherals.touchpad send-events disabled
# enable the touchpad
gsettings set org.gnome.desktop.peripherals.touchpad send-events enabled
# enable the touchpad automatically if an external mouse is NOT plugged in, but
# disable it automatically if one is
gsettings set org.gnome.desktop.peripherals.touchpad send-events disabled-on-external-mouse

# get the current setting
gsettings get org.gnome.desktop.peripherals.touchpad send-events

To see what settings are available, run the gsettings range command. Here is the command and its output, showing all 3 settings options I presented above:

$ gsettings range org.gnome.desktop.peripherals.touchpad send-events
enum
'enabled'
'disabled'
'disabled-on-external-mouse'

The way I figured this stuff out is by digging around in the dconf-editor settings to explore what settings and options existed.

Install it with:

sudo apt update
sudo apt install dconf-editor

Here is a screenshot of the org.gnome.desktop.peripherals.touchpad settings page in it:

enter image description here

Note also that you can open your regular Ubuntu "Settings" --> "Mouse & Touchpad" --> and view the "Touchpad" enable toggle turn on and off as you manually run the enable/disable command-line commands above:

enter image description here

To figure out how to disable other external devices, such as touchscreens, trackballs, tracksticks, etc, go up a couple levels to the org.gnome.desktop.peripherals section of the dconf-editor, and drill down to explore their settings from there:

enter image description here

See also

  1. My touchpad_toggle.sh script which uses the code above and is part of my eRCaGuy_dotfiles repo. It allows you to rapidly enable/disable your touchpad and/or touchscreen, as well as fix your mouse wheel scroll speed simultaneously. I've used it on Ubuntu 14.04, 16.04, 18.04, 20.04, and 22.04, using both the Wayland and X11 window servers on Ubuntu 22.04. See also my answer here: How to permanently fix scroll speed in Chrome, Sublime Text, Foxit PDF reader, and any other application you see fit.
  2. My answer which links to this one: Enable/disable touchpad
2
  • 1
    disabled-on-external-mouse seems to work well. That's really cool!
    – hat
    Aug 15, 2023 at 8:24
  • 1
    Thanks! This worked great on one of my laptops (an XPS 13 9315 on Ubuntu 23.04) but not on the other (an XPS 13 9350 on Ubuntu 22.04). Both were on X. The commands worked on the other (and the setting was changed from enabled to disabled) but did not have an effect.
    – scottkosty
    Aug 29, 2023 at 3:19
0

I was able to restore normal function to the touchpad settings app and the touchpad on/off button by removing unity and its settings app - I am now set up with a plain GNOME system and the touchpad control works normally.

1
  • Can you elaborate more on "removing unity and its settings app"?
    – FedKad
    Jun 4, 2022 at 11:09
0

The above solutions worked great for me under the previous release, but after upgrading to 22.04, they are no longer effective. Removing xserver-xorg-input-synaptics did not change anything, and when I try using xinput -disable (or setting the state to 0), I receive the following message: "WARNING: running xinput against an Xwayland server. See the xinput man page for details." This is making my computer extremely difficult to use.

1
0

I had the same issue, and I felt the other solutions were quite complicated. The easiest solution I found was to install Touchpad-Indicator.
In this program, I was able to easily enable and disable the touch pad and even set alternative keyboard shortcuts for the same.

0

2023 ubuntu 22.04

best answer we have found - script to toggle touchpad

special thanks to pinbo for this script: https://gist.github.com/pinbo/48372ba323629199b646ea58fbf036e5

touchpad.sh:

#!/bin/bash
# the code is written by steeve.mccauley from: https://extensions.gnome.org/extension/935/toggle-touchpad/
# I tested on Gnome 3.38.2 on 2020-12-17. It works perfectly.
# Then added a keyboard shortcut to easy run the script to turn on or off the laptop touchpad.
class=org.gnome.desktop.peripherals.touchpad #location in gconf settings where the touchpad is en/disabled
name=send-events #name of the actual setting
status=$(gsettings get "$class" "$name")
status=${status,,} # normalize to lower case; this is a modern bash extension

echo Current status is $status
if [[ $status = "'disabled'" ]]; then # needs " ' '" to work
echo it is off
new_status=enabled # ' not required
else
new_status=disabled
fi
echo "Toggling to $new_status"
gsettings set "$class" "$name" "$new_status"
  1. Save this script as touchpad.sh
  2. Make it executable - chmod +x touchpad.sh
  3. Create a custom shortcut in Ubuntu.

Mine was F4 to toggle.

Set the command to

/bin/bash /home/user/Desktop/touchpad.sh

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .