#!/usr/bin/env bash # 开发模式在 Linux 上运行(不安装,直接用仓库里的 out/ + electron) # scripts/linux/run.sh [electron 参数...] set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" cd "$ROOT" ELECTRON="node_modules/electron/dist/electron" if [ ! -x "$ELECTRON" ]; then echo "[run] 先安装依赖…" npm install --no-audit --no-fund if [ ! -x "$ELECTRON" ]; then ELECTRON_MIRROR="${ELECTRON_MIRROR:-https://npmmirror.com/mirrors/electron/}" \ node node_modules/electron/install.js fi fi [ -f out/main/index.js ] || npm run build ozone="${SODIUM_PET_OZONE:-auto}" if [ "$ozone" = "auto" ]; then if [ -n "${WAYLAND_DISPLAY:-}" ] || [ "${XDG_SESSION_TYPE:-}" = "wayland" ]; then if [ -n "${DISPLAY:-}" ]; then ozone="x11"; else ozone="wayland"; fi else ozone="x11" fi fi if [ "$ozone" = "x11" ] && [ -z "${DISPLAY:-}" ]; then echo "[run] 没有 DISPLAY,改用原生 Wayland(窗口位置/置顶会受限)" >&2 ozone="wayland" fi echo "[run] backend=$ozone" exec "$ELECTRON" --ozone-platform="$ozone" . "$@"