Created
October 23, 2013 01:32
-
-
Save weskerfoot/7111033 to your computer and use it in GitHub Desktop.
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/python2 | |
from re import split | |
from subprocess import check_output as call | |
from sys import argv | |
def apply(f, *args): | |
return f(args) | |
output = apply(call, "/usr/bin/xinput", "--list").split("\n") | |
for line in output: | |
if "Mouse" in line: | |
line = line.split('=')[1] | |
line = split(r'([0-9]+)', line) | |
if len(line) > 2 and len(argv) > 1: | |
if argv[1] == "disable": | |
apply(call, "xinput", "set-int-prop", line[1], "Device Enabled", "8", "0") | |
else: | |
apply(call, "xinput", "set-int-prop", line[1], "Device Enabled", "8", "1") | |
else: | |
isenabled = apply(call, "/usr/bin/xinput", "list-props", line[1]).split("\n") | |
for line2 in isenabled: | |
if "Device Enabled" in line2: | |
line2 = split(r'([0-9]+)', line2) | |
print line2[3] | |
if line2[3] == "0": | |
# it is disabled, so enable | |
apply(call, "xinput", "set-int-prop", line[1], "Device Enabled", "8", "1") | |
else: | |
apply(call, "xinput", "set-int-prop", line[1], "Device Enabled", "8", "0") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment