From e880f9d2fc49da72a1e6ff010cde2959234f76f0 Mon Sep 17 00:00:00 2001 From: Gloridust Date: Sun, 5 Jul 2026 00:55:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=A3=81=E7=BA=B8):=20resize=20=E5=90=8E?= =?UTF-8?q?=E5=A3=81=E7=BA=B8=E8=A2=AB=E5=B9=B3=E9=93=BA=20=E2=80=94?= =?UTF-8?q?=E2=80=94=20=E6=94=B9=E4=B8=BA=E5=88=86=E8=BE=A8=E7=8E=87?= =?UTF-8?q?=E5=8F=98=E5=8C=96=E5=8D=B3=E9=87=8D=E8=AE=BE=EF=BC=88issue=20?= =?UTF-8?q?=E5=8F=8D=E9=A6=88=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit autostart 在 Xvnc 默认分辨率下设一次壁纸;浏览器连上后 KasmVNC resize-remote 把屏幕变大, X 就把当时的小 root pixmap 平铺填满(表现为壁纸 2×2 平铺)。改为后台看守:每 2s 检查 「壁纸名@分辨率」签名,一变就 --zoom 重设,跨 resize/换壁纸都保持正确。冒烟验证不阻断启动。 --- docker/autostart | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/docker/autostart b/docker/autostart index 409d8e6..a40883f 100644 --- a/docker/autostart +++ b/docker/autostart @@ -47,17 +47,27 @@ if [ "$APP_TYPE" = "custom" ] && [ -z "${APP_LAUNCH:-}" ]; then exit 0 fi -# 1) 应用壁纸(若用户设置了自定义背景图) +# 1) 应用壁纸(若用户设置了自定义背景图)。 +# 关键:Xvnc 启动时是默认分辨率,浏览器连上后 KasmVNC 会 resize-remote 到浏览器尺寸。若只在启动时设一次, +# 屏幕一变大,X 会把当时设的小尺寸 root pixmap【平铺】填满新屏(表现为壁纸被 2×2 平铺,见 issue 反馈)。 +# 故用看守:每 2s 检查分辨率,一变就用 --zoom(填充裁切、保持比例)重设壁纸。也顺带跟随面板对壁纸文件的改动。 WALLPAPER_FILE="/config/.wallpaper" WALLPAPER_DIR="/config/backgrounds" -if [ -f "$WALLPAPER_FILE" ]; then - wp=$(cat "$WALLPAPER_FILE") - if [ -n "$wp" ] && [ -f "$WALLPAPER_DIR/$wp" ]; then - export DISPLAY="${DISPLAY:-:1}" - xwallpaper --zoom "$WALLPAPER_DIR/$wp" 2>/dev/null && \ - echo "[autostart] 壁纸已应用: $wp" - fi -fi +( + export DISPLAY="${DISPLAY:-:1}" + last="" + while sleep 2; do + [ -f "$WALLPAPER_FILE" ] || { last=""; continue; } + wp=$(cat "$WALLPAPER_FILE" 2>/dev/null) || continue + [ -n "$wp" ] && [ -f "$WALLPAPER_DIR/$wp" ] || { last=""; continue; } + # 用「分辨率 + 壁纸名」做签名:分辨率变(resize)或换了壁纸都会重设 + sig="${wp}@$(xrandr 2>/dev/null | grep -o '[0-9]\+x[0-9]\+' | head -1)" + if [ "$sig" != "$last" ]; then + last="$sig" + xwallpaper --zoom "$WALLPAPER_DIR/$wp" 2>/dev/null && echo "[autostart] 壁纸已应用/重设: $sig" + fi + done +) & # 2) 应用自定义字体(若用户设置了) # 从持久卷恢复系统级 fontconfig 配置(跨越容器重建)