From: mar77i Date: Fri, 27 Dec 2024 11:20:49 +0000 (+0100) Subject: xinput: specify imports from subrocess X-Git-Url: https://git.mar77i.info/?a=commitdiff_plain;h=48f7e2bb36443111c24049e0e65a0b2ee0928103;p=zenbook_conf xinput: specify imports from subrocess --- diff --git a/xinput.py b/xinput.py index 5c6f4ef..0dc586a 100644 --- a/xinput.py +++ b/xinput.py @@ -1,6 +1,6 @@ import os import re -import subprocess +from subprocess import DEVNULL, check_output, run class XinputConf: @@ -49,7 +49,7 @@ 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) @@ -72,13 +72,13 @@ class XinputConf: 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):