Appearance
Desktop
The desktop template ships an XFCE desktop with Xvfb, x11vnc and noVNC preinstalled — a real graphical session for GUI applications that have no headless mode.
Browser access needs the ingress gateway
noVNC is entirely WebSocket-based, and public sandbox endpoints are HTTP only today, so viewing the desktop in your own browser arrives with the ingress gateway. What works now is running GUI applications on the virtual display and taking the output back out as files.
Setup
bash
pip install ovrin
export OVRIN_API_KEY="ovrin_..."Start the display
python
import ovrin
client = ovrin.Client() # reads OVRIN_API_KEY
sandbox = client.sandboxes.create(template="desktop", timeout=3600)
sandbox.run("nohup Xvfb :0 -screen 0 1280x800x24 > /tmp/xvfb.log 2>&1 &")
sandbox.run("sleep 1 && DISPLAY=:0 nohup dbus-launch startxfce4 > /tmp/xfce.log 2>&1 &")Run a GUI application and take the result
python
sandbox.run("DISPLAY=:0 nohup xterm -e 'echo hello; sleep 30' > /dev/null 2>&1 &")
# Capture the virtual display and pull the image back.
sandbox.run("sleep 2 && DISPLAY=:0 import -window root /workspace/screen.png")
png = sandbox.files.read_bytes("/workspace/screen.png")
open("screen.png", "wb").write(png)
sandbox.kill()Adding VNC
x11vnc is installed if you want a VNC server running inside the sandbox, for example to reach it from another process in the same sandbox:
python
sandbox.run(
'nohup x11vnc -display :0 -passwd "$VNC_PASSWORD" -forever -shared '
"-rfbport 5900 > /tmp/x11vnc.log 2>&1 &"
)Pass VNC_PASSWORD through env at creation. Never reuse a password you use anywhere else: it protects a screen, not an account.
Related
- Agent environments — every template
- Chrome — a browser sandbox with DevTools