#!/bin/bash declare -r entropy=$(xxd -l16 -ps /dev/urandom) #declare -r CHROME_DIR="${HOME}/.chromeDevTemp" declare -r chrome_dir="/tmp/chrome/${entropy}" # See flags available and documentation: # https://chromium.googlesource.com/chromium/src/+/HEAD/chrome/common/chrome_switches.cc # https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md # https://peter.sh/experiments/chromium-command-line-switches/ # NB: Creating the directory first seems to block process start. # Perhaps this is the wrong chmod ownership flags. #mkdir -p $CHROME_DIR #--auto-open-devtools-for-tabs="true" \ #--devtools-flags="" \ # TODO(bt): Math to determine better window placement. launch_linux() { chromium \ --allow-running-insecure-content \ --disable-features=ChromeLabs \ --disable-site-isolation-trials \ --disable-web-security \ --ignore-certificate-errors \ --install-autogenerated-theme="100,150,255" \ --unsafely-treat-insecure-origin-as-secure="http://localhost:5173" \ --user-data-dir="${chrome_dir}" \ --window-position=1200,300 \ --window-size=1500,1700 \ http://localhost:5173 } launch_mac() { # See https://stackoverflow.com/a/58658101 # NB: '7001' port is being chosen because something on the system is hogging port 7000. # chrome://flags/#unsafely-treat-insecure-origin-as-secure - allow microphone recording # otherwise getUserMedia() / navigator.mediaDevices will not function # --guest: no Google login screen open -na "Google Chrome" --args \ --disable-features=ChromeLabs \ --disable-site-isolation-trials \ --disable-web-security \ --ignore-certificate-errors \ --install-autogenerated-theme="100,150,255" \ --unsafely-treat-insecure-origin-as-secure="http://localhost:5173" \ --user-data-dir="${chrome_dir}" \ --window-position=1200,300 \ --window-size=1500,1700 \ --guest \ http://localhost:5173 } case $OSTYPE in linux*) launch_linux ;; darwin*) launch_mac ;; *) echo "Unknown OS" ;; esac