From dcb607e5522294c8b632a2b832281198ff667546 Mon Sep 17 00:00:00 2001 From: bepis Date: Thu, 23 Apr 2026 13:14:03 +1000 Subject: [PATCH] Updated script to support X11 --- README.md | 2 +- main.py | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2759f9f..e44ffc7 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ sudo usermod -aG input $USER # Log out and back in for this to take effect ``` -## Steam Launch Script +## Steam Launch Script (Skip if using X11) Save the following as `~/.local/bin/taptaploot-forward.sh` (or download from the repo above) and make it executable (`chmod +x`): diff --git a/main.py b/main.py index 9c7adb0..b9f3494 100644 --- a/main.py +++ b/main.py @@ -21,7 +21,22 @@ keyboard_threads = [] keyboard_devices = [] TARGET_WINDOW_NAME = 'TapTapLoot' -TARGET_DISPLAY = ':10' + +def detect_display(): + """Use Xwayland display if launch script is running, otherwise fall back to current $DISPLAY""" + xauth_files = glob.glob('/tmp/taptaploot-xauth.*') + if xauth_files: + # Extract display number from the xauth file + import subprocess + result = subprocess.getoutput(f"xauth -f {xauth_files[0]} list") + for line in result.splitlines(): + if line.startswith(':'): + return line.split('/')[0].strip() + return ':10' # fallback if parsing fails + # No xauth file = native X11, use current display + return os.environ.get('DISPLAY', ':0') + +TARGET_DISPLAY = detect_display() def get_xauth_path(): """Dynamically find the current taptaploot xauth file"""