-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchode-launcher.py
More file actions
66 lines (56 loc) · 2.06 KB
/
Copy pathchode-launcher.py
File metadata and controls
66 lines (56 loc) · 2.06 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
"""
chode-start — Cross-platform splash launcher for Chad Code (CHODE v0.5.0)
Works seamlessly across macOS, Linux, and Windows.
"""
import os
import sys
import shutil
import subprocess
import platform
from pathlib import Path
def main():
script_dir = Path(__file__).parent.resolve()
# 1. Resolve splash file
splash_env = os.environ.get("CHODE_SPLASH")
if splash_env:
splash_path = Path(splash_env)
else:
splash_path = Path.home() / ".chode" / "splash.mp4"
if not splash_path.exists():
splash_path = script_dir / "splash.mp4"
skip_splash = os.environ.get("CHODE_NO_SPLASH") == "1"
# 2. Render splash if video exists and stdout is interactive TTY
if splash_path.exists() and not skip_splash and sys.stdout.isatty():
chode_splash_py = script_dir / "chode_splash.py"
ffmpeg_bin = shutil.which("ffmpeg")
mpv_bin = shutil.which("mpv")
ffplay_bin = shutil.which("ffplay")
if ffmpeg_bin and chode_splash_py.exists():
try:
subprocess.run([sys.executable, str(chode_splash_py), str(splash_path)], check=False)
except Exception:
pass
elif mpv_bin:
try:
subprocess.run([mpv_bin, "--vo=tct", "--really-quiet", "--length=10", str(splash_path)], check=False)
except Exception:
pass
elif ffplay_bin:
try:
subprocess.run([ffplay_bin, "-autoexit", "-fs", "-loglevel", "quiet", str(splash_path)], check=False)
except Exception:
pass
# 3. Launch main CHODE process
chode_py = script_dir / "chode.py"
if not chode_py.exists():
print(f"Error: chode.py not found at {chode_py}")
sys.exit(1)
cmd = [sys.executable, str(chode_py)] + sys.argv[1:]
# On POSIX (Mac/Linux), replace process; on Windows, run and exit
if os.name != "nt":
os.execv(sys.executable, cmd)
else:
sys.exit(subprocess.call(cmd))
if __name__ == "__main__":
main()