Files
SodiumPet/scripts/linux/run.sh
T
deepseek 9313704918 feat(linux): 支持 Linux / Wayland 桌面运行
- 新增 src/main/platform.ts:Ozone 后端选择(Wayland 优先 XWayland)、
  能力降级封装、XDG 数据目录、缺参 relaunch
- 主进程窗口定位/置顶/跨工作区/拖拽/视线跟随改为平台能力封装
- 托盘失败容错、Linux 窗口图标、pet:// 缺失文件返回 404
- 新增 scripts/linux/{install,run,uninstall}.sh 与启动器、desktop 菜单项、自启动
- 新增 assets/linux 应用图标;README 增加 Linux/Wayland 文档
- 清理仓库根目录误提交的 Chromium 日志文件
2026-12-02 05:13:49 +09:00

35 lines
1.1 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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" . "$@"