| import subprocess |
| import time |
| import sys |
| import os |
|
|
| def run_bg(command): |
| |
| return subprocess.Popen( |
| command, |
| shell=True, |
| env={**os.environ, "DISPLAY": ":1"} |
| ) |
|
|
| def main(): |
| print(">>> Initializing Environment...") |
|
|
| |
| |
| vnc_dir = os.path.join(os.environ['HOME'], '.vnc') |
| os.makedirs(vnc_dir, exist_ok=True) |
| |
| yaml_config = """ |
| network: |
| protocol: http |
| interface: 0.0.0.0 |
| websocket_port: 7860 |
| ssl: |
| require_ssl: false |
| """ |
| with open(os.path.join(vnc_dir, 'kasmvnc.yaml'), 'w') as f: |
| f.write(yaml_config) |
|
|
| |
| |
| print(">>> Starting KasmVNC on Port 7860...") |
| run_bg("vncserver -select-de matchbox -geometry 1280x720 -depth 24 -http_port 7860 -websocket_port 7860 -SecurityTypes None") |
| |
| |
| time.sleep(3) |
|
|
| |
| print(">>> Starting Window Manager...") |
| run_bg("matchbox-window-manager -use_titlebar no") |
|
|
| |
| print(">>> Starting Brave Browser...") |
| brave_cmd = ( |
| "brave-browser " |
| "--start-maximized " |
| "--user-data-dir=/home/user/brave-data " |
| "--no-sandbox " |
| "--disable-dev-shm-usage " |
| "--disable-gpu-shader-disk-cache " |
| "--test-type " |
| |
| "--disable-gpu-compositing " |
| ) |
| |
| |
| while True: |
| try: |
| |
| subprocess.run(brave_cmd, shell=True, env={**os.environ, "DISPLAY": ":1"}) |
| time.sleep(1) |
| except KeyboardInterrupt: |
| print(">>> Stopping services...") |
| sys.exit(0) |
|
|
| if __name__ == "__main__": |
| main() |