#!/usr/bin/env sh # ~/.local/bin/chromium # chromium plaintext configuration overlay script # mangles configuration during pre-run # useragent string # fake being MS edge on windows to avoid cloudflare serving webp/avif images UA_STRING="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 \ (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.2592.102" # allow multiple chromium profiles to co-exist by deriving profile name from # script name, eg. this script being renamed or symlinked as 'chrome-temp' will # use profile located at '~/.config/chrome-temp' CONF="$HOME/.config/${0##*/}" # redirect cache writes to ramdisk defined by pam_systemd CACHE="$XDG_CACHE_HOME/${0##*/}" # DO NOT mangle config if chromium is already running if ! ps -e | fgrep -q 'chromium'; then # on first-run, regenerate chromium config if [ ! -d "$CONF/Default" ]; then # dumb hack to checkout persistent settings if not found mkdir -p "$CONF" git meta list-files | fgrep '.config/chromium' \ | xargs -I'{}' git meta --work-tree="$CONF" checkout "{}" cd "$CONF/.config/chromium" && mv * ../.. && rm -rf '.config/chromium' # warn user of first run # allow first run to generate default preferences # automatically enable use of theme colors cat <<- EOF | /usr/bin/chromium "data:text/html;base64,$(base64 -w 0)" \ --install-autogenerated-theme='0,0,0' -incognito &
chromium
preferences on first run...This only needs to be done once.
DO NOT interact with this window,
chromium
will restart momentarily.