before its fucked again

This commit is contained in:
2026-02-23 05:31:33 +01:00
parent 831d76c10e
commit 0d7a51ddcd
8 changed files with 686 additions and 137 deletions

56
client/wayland-helper.py Executable file
View File

@@ -0,0 +1,56 @@
#!/usr/bin/env python3
import json
import subprocess
import os
def get_wayland_windows():
"""
Since Wayland aggressively isolates window metadata from standard utilities,
and KWin DBus scripts are restricted on this machine, we check for common
running GUI applications via `ps` to label the composite pipewire sink.
"""
windows = []
# Try XWayland fallback first
try:
wmctrl_out = subprocess.run(['wmctrl', '-l'], capture_output=True, text=True, timeout=1).stdout
for line in wmctrl_out.splitlines():
parts = line.split(maxsplit=3)
if len(parts) >= 4:
windows.append({"title": parts[3]})
except Exception:
pass
# Process scraping for common GUI apps on Wayland
try:
ps_out = subprocess.run(['ps', '-eo', 'comm='], capture_output=True, text=True).stdout
running_procs = ps_out.lower().splitlines()
common_apps = {
'spotify': 'Spotify',
'discord': 'Discord',
'chrome': 'Google Chrome',
'chromium': 'Chromium',
'firefox': 'Firefox',
'code': 'VS Code',
'obsidian': 'Obsidian',
'telegram': 'Telegram',
'slack': 'Slack',
'steam': 'Steam'
}
for proc, name in common_apps.items():
if proc in running_procs and not any(name in w["title"] for w in windows):
windows.append({"title": name})
except Exception:
pass
# If we found absolutely nothing, provide a generic fallback
if not windows:
windows.append({"title": "Wayland Desktop / App"})
print(json.dumps(windows))
if __name__ == '__main__':
get_wayland_windows()