Disable Touchpad when external mouse is connected on GNOME

According to the Steam Hardware and software survey, Ubuntu 22.04.1 LTS is used by 11.74% of all the Linux gamers. And it just stands at the first place among all the Linux distributions when it comes to Linux desktops (Although overall it stands at the 2nd place because of the Steam Deck which has 22.08% of all the Linux users).

And Canonical’s Ubuntu primarily uses the GNOME desktop environment, which is currently on the version 42 which is great if you are on a Laptop device because of the gesture support. But this boon can be a curse, specially while gaming. Whenever you play games on your laptop with an external mouse connected, there are chances that you will accidentally touch your touchpad and that will result in poor aim and unnecessary disturbances.

Therefore, it would be a wise move to disable the touchpad device whenever you are gaming or, simply let Linux disable it for you whenever it will detect an external mouse.

The GNOME settings application has a ton of customizations for your input device such as natural scrolling, speed and disabling the touchpad permanently, but there is no such option to deactivate the device conditionally.

Also Read : How to Install GNOME Tweak tool on Ubuntu

However, you can easily achieve this goal by working through the command line or through the Dconf editor. In this tutorial, I will show you how to do exactly that.

Configure touchpad on Linux using GUI

Before we proceed, make sure that you have configured the touchpad settings as per your need, because when we are done with the customizations, you won’t be able to access it even if no external mouse is connected. To do that, just open the settings window and go to Mouse & Touchpad section.

Customize Your Touchpad Settings Before We Begin
Customize Your Touchpad Settings Before We Begin

Once you are done, simply close the window.

Disable touchpad when external mouse is connected

Let’s now get to disabling the touchpad automatically when you connect an external mouse.

The Graphical Way

If you are using Ubuntu, then open Dconf editor while plugging in an external mouse and then go into /org/gnome/desktop/peripherals/touchpad/send-events and disable the touchpad by toggling off the ‘Default Value’ and entering the custom value ‘disable-on-external-mouse’.

Disabling Touchpad Whenever An External Mouse Is Plugged In
Disabling Touchpad Whenever An External Mouse Is Plugged In

Finally, click on the ‘Apply’ button and close this window.

If you are on any other Linux distribution where Dconf editor is not installed, then you can install it by typing the following commands:

# On Fedora Workstation
sudo dnf install dconf editor

# On Arch Linux based distributions
sudo pacman -s dconf-editor
Installing Dconf Editor On Fedora
Installing Dconf Editor On Fedora

The Command Line Method

If you are more comfortable using the command line, then you can do the above customizations by typing a single command in the Terminal without installing any program. Just type the following in your Terminal window, irrespective of your Linux distribution:

gsettings set org.gnome.desktop.peripherals.touchpad send-events disabled-on-external-mouse
A Single Command To Disable The Touchpad Whenever An External Mouse Is Connected
A Single Command To Disable The Touchpad Whenever An External Mouse Is Connected

Just in case if you do not like the customizations which we made, you can type the following command to undo the changes:

gsettings set org.gnome.desktop.peripherals.touchpad send-events enabled

There is also a Touchpad Indicator GNOME extension which you can install to disable or enable the devices directly from your system tray. However, it currently only supports GNOME 40, so it might be incompatible at the time until the developer updates it or someone forks the project.

Summary

You can also disable the touchpad while you are typing by configuring the settings using the GNOME Tweaks application if you regularly type and your hands often slip on the touchpad. Or, by typing the following commands in your Terminal:

gsettings set org.gnome.desktop.peripherals.touchpad disable-while-typing true

Why these settings are hidden away in these applications instead of the Settings Menu? Well, on the GNOME developers know. But because of the Linux distribution’s customizability, you can do anything by using a few workarounds.

Links in article: