0%

Automatically Disable Touchpad When External Mouse Is Connected (Ubuntu)

When I want to set Touchpad to automatically switch the “disabled” or “enabled” according to whether an external mouse is currently connected, but I failed to find the settings that can be achieved in Settings > Devices > Mouse & Touchpad

Found a high-quality answer from awesome guy Jacob Vlijm : Reference

Edit Aliases

Add some aliases like following content in ~/.bash_aliases

E.g:

1
2
3
4
alias touchpad:status="gsettings get org.gnome.desktop.peripherals.touchpad send-events"
alias touchpad:on="gsettings set org.gnome.desktop.peripherals.touchpad send-events enabled"
alias touchpad:off="gsettings set org.gnome.desktop.peripherals.touchpad send-events disabled"
alias touchpad:auto="gsettings set org.gnome.desktop.peripherals.touchpad send-events disabled-on-external-mouse"

After saving, execute

1
source ~/.bash_aliases

Test

view current status of the touchpad

1
2
3
touchpad:status

# will output: 'enabled' | 'disabled' | 'disabled-on-external-mouse'

turn on

1
touchpad:on

turn off

1
touchpad:off

auto switching

1
2
3
touchpad:auto

# automatically disable touchpad when mouse connected and enable touchpad when mouse disconnected

🔓

Done! O(∩ _ ∩)O~