#!/bin/bash
# Brave Origin's launcher: extra command-line flags, one per line, come from ~/.config/brave-origin-flags.conf
# (blank lines and lines starting with # are skipped), as with Brave's own recipe.
set -euo pipefail
conf="${XDG_CONFIG_HOME:-$HOME/.config}/brave-origin-flags.conf"
# Brave documents this Linux-only switch for its free Origin edition.
flags=(--skip-origin-startup-dialog --no-first-run)
if [ -f "$conf" ]; then
  while IFS= read -r line || [ -n "$line" ]; do
    [[ "$line" =~ ^[[:space:]]*(#|$) ]] || flags+=("$line")
  done < "$conf"
fi
export CHROME_VERSION_EXTRA=stable
exec /opt/brave-origin-bin/brave-origin "${flags[@]}" "$@"
