import os
import re
-import subprocess
+from subprocess import DEVNULL, check_output, run
class XinputConf:
self.conf = self.get_conf()
def get_conf(self):
- output = subprocess.check_output(["xinput", "list"], text=True)
+ output = check_output(["xinput", "list"], text=True)
devices = []
for line in output.split(os.linesep):
match = self.DEVICE_PATTERN.match(line)
if enable is None:
enable = device["enabled"]
if enable:
- subprocess.run(["xinput", "enable", device["id"]])
- subprocess.run(
+ run(["xinput", "enable", device["id"]])
+ run(
["xinput", "map-to-output", device["id"], device["output"]],
- stderr=subprocess.DEVNULL if device.get("ignore_result") else None,
+ stderr=DEVNULL if device.get("ignore_result") else None,
)
else:
- subprocess.run(["xinput", "disable", device["id"]])
+ run(["xinput", "disable", device["id"]])
self.conf = self.get_conf()
def update(self, mode):