dotfiles/.bin/chrome
2025-01-18 09:10:20 +01:00

147 lines
4.9 KiB
Bash
Executable File

#!/bin/sh
# flag documentation:
# https://peter.sh/experiments/chromium-command-line-switches/
# helper functions
addflag() { FLAGS="$FLAGS $1"; }
enable() { ENABLED_FEATURES="$ENABLED_FEATURES $1"; }
disable() { DISABLED_FEATURES="$DISABLED_FEATURES $1"; }
###
### SETUP ENVIRONMENT
###
# disable WASM (OpenBSD specific)
#export ENABLE_WASM=0
# Nuke DBUS
# some webpages suggest value "disabled:"
export DBUS_SESSION_BUS_ADDRESS="unix:path=/dev/null"
###
### CHROMIUM FLAGS
###
# disable pledge (OpenBSD specific)
#addflag "--no-sandbox"
# disable unveil (OpenBSD specific)
#addflag "--disable-unveil"
# Skip First Run tasks as well as not showing additional dialogs,
# prompts or bubbles. Suppressing dialogs, prompts, and bubbles is
# important as this switch is used by automation (including performance
# benchmarks) where it's important only a browser window is shown. This
# may not actually be the first run or the What's New page. Overridden
# by kForceFirstRun (for FRE) and kForceWhatsNew (for What's New). This
# does not drop the First Run sentinel and thus doesn't prevent first run
# from occurring the next time chrome is launched without this flag. It
# also does not update the last What's New milestone, so does not prevent
# What's New from occurring the next time chrome is launched without this
# flag.
addflag "--no-first-run"
# Enables TLS/SSL errors on localhost to be ignored (no interstitial, no
# blocking of requests).
addflag "--allow-insecure-localhost"
# If present animations are disabled
addflag "--wm-window-animations-disabled"
# Select which implementation of GL the GPU process should use.
# Options are:
# desktop: whatever desktop OpenGL the user has installed (Linux and Mac default).
# egl: whatever EGL / GLES2 the user has installed (Windows default - actually ANGLE).
# swiftshader: The SwiftShader software renderer.
addflag "--use-gl=desktop"
# Disable structured metrics logging of cros actions.
addflag "--structured-metrics-disabled"
# Enables cros disks fake behavior. If the switch is set, fake cros disk
# D-Bus client is initialized and USB events do not reach chrome.
addflag "--cros-disks-fake"
# Specifies which encryption storage backend to use. Possible values are
# kwallet, kwallet5, kwallet6, gnome-libsecret, basic. Any other value
# will lead to Chrome detecting the best backend automatically.
addflag "--password-store=basic"
# Disables the service process from adding itself as an autorun process.
# This does not delete existing autorun registrations, it just prevents
# the service from registering a new one.
addflag "--no-service-autorun"
# Prevent downloading and running the recovery component.
addflag "--no-recovery-component"
addflag "--no-proxy-server"
addflag "--no-experiments"
addflag "--no-default-browser-check"
addflag "--log-level=0"
addflag "--high-dpi-support=1"
addflag "--hide-crash-restore-bubble"
addflag "--force-device-scale-factor=1.5"
addflag "--force-dark-mode"
addflag "--enable-gpu-rasterization"
addflag "--enable-zero-copy"
# addflag "--enable-unsafe-webgpu" # leads to banner "stability and security will suffer
addflag "--ignore-gpu-blocklist"
# fix webcam issues?
# addflag "--disable-yuv-image-decoding"
#
addflag "--disable-usb-keyboard-detect"
addflag "--disable-touch-drag-drop"
addflag "--disable-stack-profiler"
#addflag "--disable-software-rasterizer"
addflag "--disable-pinch"
addflag "--disable-notifications"
addflag "--disable-login-animations"
addflag "--disable-logging"
addflag "--disable-infobars"
addflag "--disable-in-process-stack-traces"
addflag "--disable-histogram-customizer"
addflag "--disable-field-trial-config"
addflag "--disable-device-discovery-notifications"
# addflag "--disable-dev-shm-usage"
addflag "--disable-default-apps"
# Disable crash reporting
addflag "--disable-crash-reporter"
addflag "--disable-cookie-encryption"
addflag "--disable-component-update"
addflag "--disable-component-cloud-policy"
addflag "--disable-cloud-print-proxy"
addflag "--disable-client-side-phishing-detection"
addflag "--disable-chrome-browser-cloud-management"
addflag "--disable-breakpad"
addflag "--disable-auto-reload"
# addflag "--dbus-stub" # default on non chrome-os
addflag "--bwsi" # force guest mode (no sign-in)
###
### ENABLE / DISABLE PROCESS FEATURES
###
enable "WebUIDarkMode" # enables dark mode
# enable RunVideoCaptureServiceInBrowserProcess # fixes webcam issues by avoiding multiple /dev/video opens
enable "VaapiVideoDecoder"
enable "VaapiVideoEncoder"
disable "IndexedDBCompressValuesWithSnappy" # disable indexdb compression, speeds up facebook
disable "Vulkan"
disable "UseChromeOSDirectVideoDecoder"
enable "VaapiVideoDecodeLinuxGL"
enable "VaapiIgnoreDriverChecks"
disable "UseSkiaRenderer"
# add features to flag list
addflag "--enable-features=$(echo "$ENABLED_FEATURES" | tr -s " " | sed 's/^ //g' | tr ' ' ',')"
addflag "--enable-features=$(echo "$DISABLED_FEATURES" | tr -s " " | sed 's/^ //g' | tr ' ' ',')"
# finally start chrome...
set -x
/usr/local/bin/chrome $FLAGS --new-window "$@"