-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
47 lines (39 loc) · 1.49 KB
/
Copy pathapp.py
File metadata and controls
47 lines (39 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
app.py
------
Backend router. Detects the display environment at runtime and launches
the appropriate GUI backend.
Routing logic:
Linux + WAYLAND_DISPLAY set -> GTK4 backend (app_gtk.py)
Everything else -> customtkinter backend (app_ctk.py)
All business logic (brain.py, spotify_client.py, config.py) is shared
between both backends and is never imported here.
"""
import os
import sys
def _is_wayland() -> bool:
"""Return True when running inside a Wayland session on Linux."""
return sys.platform.startswith("linux") and bool(os.environ.get("WAYLAND_DISPLAY"))
def run() -> None:
"""
Select and launch the correct GUI backend.
Prints a helpful message and exits if a required library is missing.
"""
if _is_wayland():
# Verify PyGObject is installed before attempting to load the GTK backend.
try:
import gi # noqa: F401
except ImportError:
print(
"[error] GTK4 backend requires PyGObject.\n"
"Run the installer again, or install manually:\n"
" Debian/Ubuntu: sudo apt install python3-gi python3-gi-cairo gir1.2-gtk-4.0\n"
" Arch: sudo pacman -S python-gobject gtk4\n"
" Fedora: sudo dnf install python3-gobject gtk4\n"
)
sys.exit(1)
from app_gtk import run as gtk_run
gtk_run()
else:
from app_ctk import SpotifyAIDJApp
SpotifyAIDJApp().mainloop()