xinput.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # a script to disable/enable mouse device
4 import subprocess
5 import re
6 def getList():
7  # array of array such as:
8  # [['Virtual core pointer', 2], ['Power Button', 7], ...]
9  name_output = subprocess.check_output(["xinput", "list", "--name-only"]).split("\n")
10  id_output = subprocess.check_output(["xinput", "list", "--id-only"]).split("\n")
11  return [[name, int(id)]
12  for name, id in zip(name_output, id_output)
13  if name and id]
14 
15 def setDeviceEnable(id, enable):
16  subprocess.check_call(["xinput", "set-prop",
17  str(id), "Device Enabled", str(enable)])
18 
20  setDeviceEnable(id, 0)
21 
23  setDeviceEnable(id, 1)
24 
26  name_id_list = getList()
27  for device_name, id in name_id_list:
28  if name == device_name:
30 
32  name_id_list = getList()
33  for device_name, id in name_id_list:
34  if name == device_name:
36 
38  name_id_list = getList()
39  for device_name, id in name_id_list:
40  if re.match(regexp, device_name) is not None:
42 
44  name_id_list = getList()
45  for device_name, id in name_id_list:
46  if re.match(regexp, device_name) is not None:
def getList()
Definition: xinput.py:6
def disableDeviceById(id)
Definition: xinput.py:19
def enableDeviceByRegexp(regexp)
Definition: xinput.py:43
def setDeviceEnable(id, enable)
Definition: xinput.py:15
def enableDeviceByName(name)
Definition: xinput.py:31
def enableDeviceById(id)
Definition: xinput.py:22
def disableDeviceByRegexp(regexp)
Definition: xinput.py:37
def disableDeviceByName(name)
Definition: xinput.py:25


joy_mouse
Author(s):
autogenerated on Fri May 14 2021 02:51:44