diff --git a/src/scripts/python/util/x.py b/src/scripts/python/util/x.py index d07f72c..358e0e2 100644 --- a/src/scripts/python/util/x.py +++ b/src/scripts/python/util/x.py @@ -72,6 +72,22 @@ def create_master(name: str = "touch"): return completed.returncode +def get_xi_id_by_name(name): + """find device id from name + + Args: + name (str): name of the device + """ + completed = subprocess.run( + ["xinput list --id-only", name], capture_output=True + ) + + if completed.returncode == 1: + return -1 + else: + int(completed.stdout.decode(ENCODING)) + + def map_to_output(output, device_id): # TODO pass