← Home

Webcam preview with Helium

2025-11-08

Quick script to open a borderless webcam preview window using Helium browser. Useful for checking framing before a call.

#!/bin/bash

HTML_FILE="/tmp/webcam.html"

cat > "$HTML_FILE" <<EOF
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Webcam Preview</title>
  <style>
    html, body {
        margin: 0;
        padding: 0;
        height: 100%;
        width: 100%;
        overflow: hidden;
        background: black;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    video {
        max-width: 100vw;
        max-height: 100vh;
        width: 100%;
        height: 100%;
        object-fit: contain;
    }
  </style>
</head>
<body>
  <video id="video" autoplay playsinline></video>
  <script>
    navigator.mediaDevices.getUserMedia({ video: { width: 1280, height: 720 }, audio: false })
      .then(stream => { document.getElementById('video').srcObject = stream; })
      .catch(err => { document.body.innerHTML = '<h1 style="color:red; font-size: 2vw;">' + err + '</h1>'; });
  </script>
</body>
</html>
EOF

helium --app="file:///tmp/webcam.html" &
# UNHOLY and HORRIBLE: dismiss the camera permission prompt
sleep 2.8
xdotool search --name "Webcam" key Tab Tab Tab Return