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:
joy_mouse.xinput.enableDeviceByName
def enableDeviceByName(name)
Definition: xinput.py:31
joy_mouse.xinput.enableDeviceByRegexp
def enableDeviceByRegexp(regexp)
Definition: xinput.py:43
joy_mouse.xinput.enableDeviceById
def enableDeviceById(id)
Definition: xinput.py:22
joy_mouse.xinput.getList
def getList()
Definition: xinput.py:6
joy_mouse.xinput.setDeviceEnable
def setDeviceEnable(id, enable)
Definition: xinput.py:15
joy_mouse.xinput.disableDeviceByRegexp
def disableDeviceByRegexp(regexp)
Definition: xinput.py:37
joy_mouse.xinput.disableDeviceById
def disableDeviceById(id)
Definition: xinput.py:19
joy_mouse.xinput.disableDeviceByName
def disableDeviceByName(name)
Definition: xinput.py:25


joy_mouse
Author(s):
autogenerated on Wed Jan 24 2024 04:05:19