From 50dd3f3c0e9b80bb4ada3b280afb84b5348d925d Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Mon, 18 Nov 2019 14:55:57 +1100 Subject: [PATCH] Use constants for mouse and keyboard device names --- forward.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/forward.py b/forward.py index 467b9ab..edeac13 100755 --- a/forward.py +++ b/forward.py @@ -20,6 +20,9 @@ MOUSEHOLD_Y = 728//2 MOUSEHOLD_W = 0 MOUSEHOLD_H = 0 +DEVICE_MOUSE = 'Logitech USB Optical Mouse' +DEVICE_KEYBOARD = 'AT Translated Set 2 keyboard' + import asyncio import re import subprocess @@ -57,7 +60,7 @@ async def mouseinp(): # Get mouse device p = await asyncio.create_subprocess_exec('xinput', 'list', stdout=subprocess.PIPE) stdout, _ = await p.communicate() - device = re.search('Logitech USB Optical Mouse.*?id=([0-9]+)', stdout.decode('utf-8')).group(1) + device = re.search(DEVICE_MOUSE + '.*?id=([0-9]+)', stdout.decode('utf-8')).group(1) print('Mouse device {}'.format(device), file=sys.stderr) p_test = await asyncio.create_subprocess_exec('xinput', 'test', device, stdout=subprocess.PIPE) @@ -78,7 +81,7 @@ async def keyboardinp(): # Get keyboard device p = await asyncio.create_subprocess_exec('xinput', 'list', stdout=subprocess.PIPE) stdout, _ = await p.communicate() - device = re.search('AT Translated Set 2 keyboard.*?id=([0-9]+)', stdout.decode('utf-8')).group(1) + device = re.search(DEVICE_KEYBOARD + '.*?id=([0-9]+)', stdout.decode('utf-8')).group(1) print('Keyboard device {}'.format(device), file=sys.stderr) p_test = await asyncio.create_subprocess_exec('xinput', 'test', device, stdout=subprocess.PIPE)