diff --git a/src/scripts/python/xutil/common.py b/src/scripts/python/xutil/common.py index ec8d9c5..c7c6a86 100644 --- a/src/scripts/python/xutil/common.py +++ b/src/scripts/python/xutil/common.py @@ -33,6 +33,22 @@ def get_list_short(id): ValueError(f'id[{id}] is not registered') +def reattach(id, master): + """Reattach a device to a master + + Args: + id (str|int): name of the slave or id + master (_type_): _description_ + + TODO: Error handling should be done. BUT, if the master is not a master or + id is not valid, xinput will not do anything and nothing bad will happen :) + """ + completed = subprocess.run( + ['xinput', '--reattach', str(id), str(master)], capture_output=True) + + return completed.returncode + + def get_ids() -> List[int]: """returns list of ids registered in xinput""" completed = subprocess.run(