Skip to content

Instantly share code, notes, and snippets.

@nicklargent
Created February 22, 2023 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicklargent/584da62cccb05f52a2ef62df19a867c9 to your computer and use it in GitHub Desktop.
Save nicklargent/584da62cccb05f52a2ef62df19a867c9 to your computer and use it in GitHub Desktop.
Script to Enable/Disable touchpad on my laptop
#!/usr/bin/ruby
def notify(msg)
`notify-send -t 1500 -i emblem-important-symbolic "#{msg}"`
end
puts "Toggling touchpad on/off"
x = `xinput list | grep -i touchpad`
if x =~ /id=(\d+)/i
id = $~[1]
puts "touchpad found at deveice id #{id}"
x = `xinput list-props #{id} | grep -i 'device enabled'`
if x =~ /(\d)$/
state = $~[1]
if state == "1"
puts "disabling Touchpad"
`xinput disable #{id}`
notify("Touch Disabled")
else
puts "enabling Touchpad"
`xinput enable #{id}`
notify("Touchbad Enabled")
end
else
puts "Can't detect touchpad state"
end
else
puts "No touchpad found"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment