Touchpad enable/disable script and shortcut on Ubuntu 18.10

If your laptop doesn’t have a working switch for turning on/off your touchpad, then this post is for you.

Create a script called disenable_touchpad.sh and add the following code to it:

!/bin/bash

state=$( gsettings get org.gnome.desktop.peripherals.touchpad send-events )

if [ "$state" == "'enabled'" ];then
gsettings set org.gnome.desktop.peripherals.touchpad send-events 'disabled' \
&& notify-send -i touchpad-disabled-symbolic "Touchpad" "Disabled"
else
gsettings set org.gnome.desktop.peripherals.touchpad send-events 'enabled' \
&& notify-send -i input-touchpad-symbolic "Touchpad" "Enabled"
fi

Mark the script as executable and move it to /usr/bin:

chmod +x disenable_touchpad.sh
sudo mv disenable_touchpad.sh /usr/bin/

Open Settings -> Keyboard, scroll to the bottom and press the + sign to assign a new keyboard shortcut:

Tested on Ubuntu 18.10, should work on any gnome-shell versions anyway!

Enjoy!

Sources: https://askubuntu.com/questions/844151/enable-disable-touchpad/1109515#1109515

Unknown's avatar

About Ahmed Tawfik

Cybersecurity Professional, Systems Engineer, OSS & Linux Geek
This entry was posted in Linux and tagged , , , , . Bookmark the permalink.

Leave a comment