import subprocess import os import sys def run_xpra_brave(): port = 7860 display = ":100" # Xpra command breakdown: # --bind-tcp: Listens on port 7860 for browser connections # --html=on: Serves the HTML5 web client automatically # --daemon=no: Keeps process in foreground for logging # --exit-with-children=no: Keeps the server alive if Brave is closed # Brave Flags: # --no-sandbox: Required to run Chromium-based browsers in containers cmd = [ "xpra", "start", display, f"--bind-tcp=0.0.0.0:{port}", "--html=on", "--daemon=no", "--notifications=no", "--mdns=no", "--speaker=off", # Modern way to disable audio (replaces --audio=no) "--microphone=off", # Modern way to disable mic "--webcam=no", "--exit-with-children=no", "--start-child=brave-browser --no-sandbox", "--start-child=xterm" # Fallback terminal window ] print(f"--- BRAVE XPRA SERVER STARTING ---") print(f"Web Interface: http://localhost:{port}") print(f"Display: {display}") print(f"Note: Brave is running with --no-sandbox") print(f"-----------------------------------") try: # Start the Xpra server subprocess.run(cmd) except KeyboardInterrupt: print("\nStopping Xpra...") subprocess.run(["xpra", "stop", display]) except Exception as e: print(f"An unexpected error occurred: {e}") if __name__ == "__main__": run_xpra_brave()