GNOME Desktop: This article explains how to automatically disable the laptop touchpad when an external mouse is plugged in and how to disable the touchpad while typing.
The GNOME Settings app has various options for mice and touchpads, including setting the speed, natural scrolling, and more. You can even disable the touchpad permanently from there. But there's no option to disable the laptop touchpad while using an external mouse, or to disable the touchpad while typing, directly in Settings.
But there are settings for enabling these 2 very useful options, though they are not exposed in the Settings app. For the instructions below to work, you'll need to be using the GNOME Shell desktop and libinput.
How to automatically disable the touchpad when a mouse is plugged in (GNOME)
To disable the touchpad when plugging in an external mouse, and re-enable the touchpad upon disconnecting the mouse, you can use either Dconf Editor or a command.
But before doing this, I recommend tweaking your touchpad settings in
Settings -> Mouse & Touchpad. That's because once we enable the option to disable the touchpad while using a mouse, the touchpad settings from the Settings app are no longer available (the Touchpad shows up as disabled, even though it's enabled if no external mouse is detected; you can configure the touchpad settings once again after enabling it).