Skip to content

Instantly share code, notes, and snippets.

@pinbo
Created December 18, 2020 06:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pinbo/48372ba323629199b646ea58fbf036e5 to your computer and use it in GitHub Desktop.
Save pinbo/48372ba323629199b646ea58fbf036e5 to your computer and use it in GitHub Desktop.
A simple script to toggle on/off laptop touchpad on Gnome Desktop
#!/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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment