Files
game-server/players/p4_config/keep-steam-window.sh
bilal ab4ee8b9d6 Fix Steam login flicker with 2GB shm and stable launch scripts.
Use tini-backed entrypoint, two-phase Steam startup, and a window keeper so CEF UI and the fluxbox toolbar stay visible in Moonlight.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-27 18:47:58 +03:00

48 lines
1.2 KiB
Bash

#!/usr/bin/env bash
export DISPLAY=:99
SCREEN_W=1920
SCREEN_H=1080
TOOLBAR_H=32
find_window() {
local title="$1"
xwininfo -root -tree 2>/dev/null | grep "\"${title}\"" | head -1 | awk '{print $1}'
}
window_state() {
xwininfo -id "$1" 2>/dev/null | awk '/Map State/{print $NF}'
}
center_window() {
local wid="$1"
local geom w h x y
geom="$(xwininfo -id "${wid}" 2>/dev/null | awk '/-geometry/{print $2}')"
w="${geom%%x*}"
h="${geom#*x}"; h="${h%%+*}"
[ -n "${w}" ] && [ -n "${h}" ] || return 0
x=$(( (SCREEN_W - w) / 2 ))
y=$(( (SCREEN_H - TOOLBAR_H - h) / 2 ))
[ "${y}" -lt 0 ] && y=0
xdotool windowmove "${wid}" "${x}" "${y}" 2>/dev/null || true
}
while pgrep -u steam -f "steam -srt-logger-opened" >/dev/null 2>&1; do
wid=""
for title in "Sign in to Steam" "Steam Big Picture Mode"; do
wid="$(find_window "${title}")"
[ -n "${wid}" ] && break
done
if [ -n "${wid}" ]; then
state="$(window_state "${wid}")"
if [ "${state}" = "IsUnMapped" ] || [ -z "${state}" ]; then
xdotool windowmap "${wid}" 2>/dev/null || true
fi
xdotool windowraise "${wid}" 2>/dev/null || true
center_window "${wid}"
xdotool windowactivate "${wid}" 2>/dev/null || true
fi
sleep 0.5
done