Created
February 22, 2023 14:16
-
-
Save nicklargent/584da62cccb05f52a2ef62df19a867c9 to your computer and use it in GitHub Desktop.
Script to Enable/Disable touchpad on my laptop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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