| 
						
						
						
					 | 
					@ -1,14 +1,23 @@ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import subprocess | 
					 | 
					 | 
					import subprocess | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					from pathlib import Path | 
					 | 
					 | 
					from pathlib import Path | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import os | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					ENCODING = "utf-8" | 
					 | 
					 | 
					ENCODING = "utf-8" | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					XINPUT = "/ust/bin/xinput" | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					def exec_xinput(args: list): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    args.insert(0, XINPUT) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    _read, _write = os.pipe() | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    write_fd = os.fdopen(_write, "w", 0) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    os.read() | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					def get_list_short(): | 
					 | 
					 | 
					def get_list_short(): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    """Returns string output of the `xinput --list --short` command encoded as | 
					 | 
					 | 
					    """Returns string output of the `xinput --list --short` command encoded as | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    UTF-8""" | 
					 | 
					 | 
					    UTF-8""" | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    completed = subprocess.run( | 
					 | 
					 | 
					    completed = subprocess.run( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        ["xinput", "--list", "--short"], capture_output=True | 
					 | 
					 | 
					        [XINPUT, "--list", "--short"], capture_output=True | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					    ) | 
					 | 
					 | 
					    ) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    return completed.stdout.decode(ENCODING) | 
					 | 
					 | 
					    return completed.stdout.decode(ENCODING) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -23,7 +32,7 @@ def get_list_short_with(id): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        ValueError: in case of id not found in devices | 
					 | 
					 | 
					        ValueError: in case of id not found in devices | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    """ | 
					 | 
					 | 
					    """ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    completed = subprocess.run( | 
					 | 
					 | 
					    completed = subprocess.run( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        ["xinput", "--list", "--short", str(id)], capture_output=True | 
					 | 
					 | 
					        [XINPUT, "--list", "--short", str(id)], capture_output=True | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					    ) | 
					 | 
					 | 
					    ) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    if completed.returncode == 0: | 
					 | 
					 | 
					    if completed.returncode == 0: | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -43,7 +52,7 @@ def reattach(id, master): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    id is not valid, xinput will not do anything and nothing bad will happen :) | 
					 | 
					 | 
					    id is not valid, xinput will not do anything and nothing bad will happen :) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    """ | 
					 | 
					 | 
					    """ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    completed = subprocess.run( | 
					 | 
					 | 
					    completed = subprocess.run( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        ["xinput", "--reattach", str(id), str(master)], capture_output=True | 
					 | 
					 | 
					        [XINPUT, "--reattach", str(id), str(master)], capture_output=True | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					    ) | 
					 | 
					 | 
					    ) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    return completed.returncode | 
					 | 
					 | 
					    return completed.returncode | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -52,7 +61,7 @@ def reattach(id, master): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					def get_ids(): | 
					 | 
					 | 
					def get_ids(): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    """returns list of ids registered in xinput""" | 
					 | 
					 | 
					    """returns list of ids registered in xinput""" | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    completed = subprocess.run( | 
					 | 
					 | 
					    completed = subprocess.run( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        ["xinput", "--list", "--id-only"], capture_output=True | 
					 | 
					 | 
					        [XINPUT, "--list", "--id-only"], capture_output=True | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					    ) | 
					 | 
					 | 
					    ) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    return list(map(int, completed.stdout.decode(ENCODING).split())) | 
					 | 
					 | 
					    return list(map(int, completed.stdout.decode(ENCODING).split())) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -63,7 +72,7 @@ def create_master(name: str = "touch"): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    Args: | 
					 | 
					 | 
					    Args: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        name (str, optional): name of the master. Defaults to 'touch'. | 
					 | 
					 | 
					        name (str, optional): name of the master. Defaults to 'touch'. | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    """ | 
					 | 
					 | 
					    """ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    completed = subprocess.run(["xinput", "create-master", name]) | 
					 | 
					 | 
					    completed = subprocess.run([XINPUT, "create-master", name]) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    return completed.returncode | 
					 | 
					 | 
					    return completed.returncode | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -75,7 +84,7 @@ def get_xi_id_by_name(name): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        name (str): name of the device | 
					 | 
					 | 
					        name (str): name of the device | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    """ | 
					 | 
					 | 
					    """ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    completed = subprocess.run( | 
					 | 
					 | 
					    completed = subprocess.run( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        ["xinput", "list", "--id-only", name], capture_output=True | 
					 | 
					 | 
					        [XINPUT, "list", "--id-only", name], capture_output=True | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					    ) | 
					 | 
					 | 
					    ) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    if completed.returncode == 1: | 
					 | 
					 | 
					    if completed.returncode == 1: | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |