Created
October 31, 2014 11:22
-
-
Save Neoklosch/a6921b66f170c80e8116 to your computer and use it in GitHub Desktop.
Toggle Touchpad on Linux Mint
This file contains hidden or 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/python | |
| from subprocess import Popen, PIPE | |
| import re | |
| terminal_call = ['xinput', 'list'] | |
| regex_pattern = re.compile(r'.+TouchPad.+id=(\d+)') | |
| sec_regex_pattern = re.compile(r'.*Device (Enabled|Disabled).+:\s(\d+)') | |
| pp = Popen(terminal_call, stdout=PIPE) | |
| for ln in pp.stdout: | |
| if regex_pattern.match(ln): | |
| id = regex_pattern.findall(ln)[0] | |
| if id: | |
| props = Popen(['xinput', 'list-props', id], stdout=PIPE) | |
| for propln in props.stdout: | |
| if sec_regex_pattern.match(propln): | |
| status = sec_regex_pattern.findall(propln)[0] | |
| if status[1] == str(1): | |
| Popen(['xinput', '--disable', id]) | |
| print "TouchPad disabled" | |
| else: | |
| Popen(['xinput', '--enable', id]) | |
| print "TouchPad enabled" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment