#!/usr/bin/bash

>&2 echo 'This build of Electron is provided by the openSUSE Build Service and contains modifications.'
>&2 echo 'Please report problems with this package at https://build.opensuse.org/ and not to upstream bug trackers.'

set -euo pipefail

name=electron
flags_file="${XDG_CONFIG_HOME:-$HOME/.config}/${name}-flags.conf"

declare -a flags=()

if [[ -f "${flags_file}" ]]; then
    mapfile -t < "${flags_file}"
fi

for line in "${MAPFILE[@]:-}"; do
    if [[ ! "${line}" =~ ^[[:space:]]*#.* ]]; then
        flags+=("${line}")
    fi
done

exec /usr/lib64/${name}/electron "$@" "${flags[@]}"
