Files
SodiumPet/scripts/linux/sodiumpet-launcher.sh
T
deepseek 845fc73b89 chore: 同步上游 v0.1.1(周期表分区 / 全屏视线 / 跨平台打包)
上游 v0.1.1 重写为新的 git 历史(无共同祖先),因此以 v0.1.1 为基线
重新应用本移植分支的全部改动(不是 merge commit):

- 上游新增:周期表 s/p/d/ds/f 五大分区与自定义改色、33ms 全屏视线轮询、
  窗口表情包图标、electron-builder 跨平台目标、人设提示词 v1.0、跨平台 CI
- 保留本移植:platform.ts 能力降级、KWin 全局光标桥接、scripts/linux 安装脚本、
  Linux/Wayland 文档与致谢
- 合并视线跟随:主进程 33ms 轮询 + KWin 桥接(Wayland 原生窗口上方也有效),
  保留 NaN 复位;点击穿透在 Linux 上不传 forward
- 清理仓库根目录误提交的 Chromium 日志文件
2026-12-02 15:22:29 +09:00

81 lines
2.5 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.
#!/bin/sh
# SodiumPet Linux 启动器
#
# 由 scripts/linux/install.sh 安装到 <PREFIX>/bin/sodiumpet。
# 这里负责三件事:
# 1. 设置数据目录(SODIUM_PET_HOME,默认 <PREFIX>/home);
# 2. 选择 Chromium 显示后端:Wayland 会话优先 XWayland(窗口可定位/置顶/穿透),
# 没有 XWayland 时才退回原生 Wayland;
# 3. 个别系统禁用了非特权 user namespace 时,自动补 --no-sandbox。
set -eu
SELF="$(readlink -f "$0")"
PREFIX="$(cd "$(dirname "$SELF")/.." && pwd)"
APP_DIR="$PREFIX/app"
ELECTRON="$PREFIX/electron/electron"
if [ ! -x "$ELECTRON" ]; then
echo "SodiumPet: 找不到 $ELECTRON,请重新运行 scripts/linux/install.sh" >&2
exit 1
fi
export SODIUM_PET_HOME="${SODIUM_PET_HOME:-$PREFIX/home}"
: "${XDG_RUNTIME_DIR:=/run/user/$(id -u)}"
export XDG_RUNTIME_DIR
# ---- 显示后端 ----
ozone="${SODIUM_PET_OZONE:-auto}"
if [ "$ozone" = "auto" ]; then
if [ -n "${WAYLAND_DISPLAY:-}" ] || [ "${XDG_SESSION_TYPE:-}" = "wayland" ]; then
if [ -n "${DISPLAY:-}" ]; then
ozone="x11" # XWayland:功能完整
else
ozone="wayland" # 原生 Wayland:没有 XWayland 时的兜底
fi
else
ozone="x11"
fi
fi
if [ "$ozone" = "x11" ] && [ -z "${DISPLAY:-}" ]; then
echo "SodiumPet: 当前没有 DISPLAY,改用原生 Wayland(窗口位置/置顶会受限)" >&2
ozone="wayland"
fi
# 登录自启动时 XWayland 可能还没就绪:等一小会儿 X socket,仍没有就退回原生 Wayland
if [ "$ozone" = "x11" ]; then
disp="${DISPLAY#*:}"
disp="${disp%%.*}"
xsock="/tmp/.X11-unix/X$disp"
i=0
while [ ! -S "$xsock" ] && [ "$i" -lt 50 ]; do
sleep 0.1
i=$((i + 1))
done
if [ ! -S "$xsock" ] && [ -n "${WAYLAND_DISPLAY:-}" ]; then
echo "SodiumPet: X socket $xsock 未就绪,改用原生 Wayland" >&2
ozone="wayland"
fi
fi
EXTRA="--ozone-platform=$ozone"
# ---- 沙箱兜底 ----
if [ "${SODIUM_PET_DISABLE_SANDBOX:-0}" = "1" ]; then
EXTRA="$EXTRA --no-sandbox"
elif [ -e "$PREFIX/electron/chrome-sandbox" ] && [ ! -u "$PREFIX/electron/chrome-sandbox" ]; then
restrict="$(cat /proc/sys/kernel/apparmor_restrict_unprivileged_userns 2>/dev/null || echo 0)"
userns="$(cat /proc/sys/user/max_user_namespaces 2>/dev/null || echo 1)"
if [ "$restrict" = "1" ] || [ "$userns" = "0" ]; then
EXTRA="$EXTRA --no-sandbox"
fi
fi
mkdir -p "$PREFIX/logs"
if [ "${SODIUM_PET_LOG:-1}" = "1" ]; then
LOG="$PREFIX/logs/sodiumpet.log"
: > "$LOG"
exec "$ELECTRON" $EXTRA "$APP_DIR" "$@" >>"$LOG" 2>&1
else
exec "$ELECTRON" $EXTRA "$APP_DIR" "$@"
fi