update to 1.4.0
This commit is contained in:
1 parent
34cbc49cfd
commit
39309478a1
3 files changed
+99
-53
No files matched your search
+59
-25
@@ -2,38 +2,72 @@
|
||||
set -e
|
||||
_APPDIR="/usr/lib/@appname@"
|
||||
_RUNNAME="${_APPDIR}/@runname@"
|
||||
_OPTIONS="@options@"
|
||||
export PATH="${_APPDIR}:${PATH}"
|
||||
export LD_LIBRARY_PATH="${_APPDIR}/swiftshader:${_APPDIR}/lib:${LD_LIBRARY_PATH}"
|
||||
|
||||
# Base environment variables
|
||||
export ELECTRON_IS_DEV=0
|
||||
export ELECTRON_FORCE_IS_PACKAGED=true
|
||||
export ELECTRON_DISABLE_SECURITY_WARNINGS=true
|
||||
export NODE_ENV=production
|
||||
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||
_FLAGS_FILE="${XDG_CONFIG_HOME}/@[email protected]"
|
||||
export LD_LIBRARY_PATH="${_APPDIR}/lib:${LD_LIBRARY_PATH}"
|
||||
|
||||
# 1. Display System Optimization (X11 & Wayland)
|
||||
# Use 'auto' to allow modern Electron (v20+) to detect the best platform
|
||||
# This helps with Wayland window decorations, fractional scaling, and GPU acceleration
|
||||
export ELECTRON_OZONE_PLATFORM_HINT="${ELECTRON_OZONE_PLATFORM_HINT:-auto}"
|
||||
|
||||
# 2. Desktop Environment (DE) Compatibility
|
||||
# Set CHROME_DESKTOP to match the .desktop file for correct taskbar icon grouping
|
||||
export CHROME_DESKTOP="@[email protected]"
|
||||
|
||||
# Fix for Electron's trash implementation on different DEs
|
||||
case "${XDG_CURRENT_DESKTOP}" in
|
||||
KDE)
|
||||
export ELECTRON_TRASH="kioclient5"
|
||||
;;
|
||||
GNOME)
|
||||
export ELECTRON_TRASH="gio"
|
||||
;;
|
||||
XFCE)
|
||||
export ELECTRON_TRASH="gvfs-trash"
|
||||
;;
|
||||
*)
|
||||
# Default fallback
|
||||
;;
|
||||
esac
|
||||
|
||||
# 3. Load user-defined flags
|
||||
# The script checks for flags in the following order (later files override/append to earlier ones):
|
||||
# 1. System-wide Electron flags: $XDG_CONFIG_HOME/electron-flags.conf
|
||||
# 2. Version-specific Electron flags: $XDG_CONFIG_HOME/electron@[email protected]
|
||||
# 3. App-specific global flags: $XDG_CONFIG_HOME/@[email protected]
|
||||
# 4. App-specific directory flags: $XDG_CONFIG_HOME/@cfgdirname@/@[email protected]
|
||||
_FLAG_SOURCES=(
|
||||
"${XDG_CONFIG_HOME}/electron-flags.conf"
|
||||
"${XDG_CONFIG_HOME}/electron@[email protected]"
|
||||
"${XDG_CONFIG_HOME}/@[email protected]"
|
||||
"${XDG_CONFIG_HOME}/@cfgdirname@/@[email protected]"
|
||||
)
|
||||
|
||||
declare -a flags
|
||||
if [[ -f "${_FLAGS_FILE}" ]]; then
|
||||
mapfile -t < "${_FLAGS_FILE}"
|
||||
fi
|
||||
for line in "${MAPFILE[@]}"; do
|
||||
if [[ ! "${line}" =~ ^[[:space:]]*#.* ]] && [[ -n "${line}" ]]; then
|
||||
flags+=("${line}")
|
||||
for _FLAGS_FILE in "${_FLAG_SOURCES[@]}"; do
|
||||
if [[ -f "${_FLAGS_FILE}" ]]; then
|
||||
echo "Loading flags from ${_FLAGS_FILE}"
|
||||
while read -r line || [[ -n "$line" ]]; do
|
||||
[[ "${line}" =~ ^[[:space:]]*#.* ]] || [[ -z "${line}" ]] || {
|
||||
read -ra line_flags <<< "$line"
|
||||
flags+=("${line_flags[@]}")
|
||||
}
|
||||
done < "${_FLAGS_FILE}"
|
||||
fi
|
||||
done
|
||||
_WAYLAND_OPTION=false
|
||||
for arg in "$@"; do
|
||||
if [[ "${arg}" == "--wayland" ]]; then
|
||||
_WAYLAND_OPTION=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ "${_WAYLAND_OPTION}" == true ]]; then
|
||||
echo "Forcing Wayland"
|
||||
flags+=("--enable-features=UseOzonePlatform,WaylandWindowDecorations,VaapiVideoDecodeLinuxGL" "--ozone-platform=wayland")
|
||||
|
||||
# 4. Sandbox and Execution Permissions
|
||||
# Disable sandbox if running as root without ELECTRON_RUN_AS_NODE
|
||||
_SANDBOX_ARG=()
|
||||
if [[ "${EUID}" -eq 0 ]] && [[ "${ELECTRON_RUN_AS_NODE}" != "1" ]]; then
|
||||
_SANDBOX_ARG=("--no-sandbox")
|
||||
fi
|
||||
|
||||
cd "${_APPDIR}"
|
||||
if [[ "${EUID}" -ne 0 ]] || [[ "${ELECTRON_RUN_AS_NODE}" ]]; then
|
||||
exec electron@electronversion@ "${_RUNNAME}" "${_OPTIONS}" "${flags[@]}" "$@" || exit $?
|
||||
else
|
||||
exec electron@electronversion@ "${_RUNNAME}" "${_OPTIONS}" --no-sandbox "${flags[@]}" "$@" || exit $?
|
||||
fi
|
||||
exec electron@electronversion@ "${flags[@]}" "${_SANDBOX_ARG[@]}" "${_RUNNAME}" "$@"
|
||||
Reference in new issue
Block a user