Skip to content

Instantly share code, notes, and snippets.

@brunetton
Last active September 18, 2015 13:35
Show Gist options
  • Save brunetton/7da14a7c29a2e2bb3068 to your computer and use it in GitHub Desktop.
Save brunetton/7da14a7c29a2e2bb3068 to your computer and use it in GitHub Desktop.
Touchpad on/off switch
#!/usr/bin/python
import re
import subprocess
on_command = "synclient TouchpadOff=0"
off_command = "synclient TouchpadOff=1"
# TouchpadOff = 2
match = re.search("=\s(\d)", subprocess.check_output("synclient | grep TouchpadOff", shell=True))
if match:
value = match.group(1)
print u"value: ", value
assert value in ['0','1','2']
touchpad_is_on = value == '0'
else:
raise ''
if touchpad_is_on:
print "touchpad is on, turning it off"
subprocess.call(off_command, shell=True)
subprocess.call('notify-send -u normal "Touchpad" "Touchpad => off"', shell=True)
else:
print "touchpad is off, turning it on"
subprocess.call(on_command, shell=True)
subprocess.call('notify-send -u normal "Touchpad" "Touchpad => on"', shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment