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>
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
{
|
||||
"name": "Steam Big Picture",
|
||||
"detached": [
|
||||
"bash -lc 'id steam >/dev/null 2>&1 || useradd -m -s /bin/bash steam; ROOT=/home/steam/.local/share/Steam/debian-installation; mkdir -p ${ROOT} /tmp/xdg-steam /home/steam/tmp; ln -sfn /home/steam/.local/share/Steam /home/steam/.steam; chown -R steam:steam /home/steam /tmp/xdg-steam; pkill -u steam -f \"steam|steamwebhelper|steam-runtime\" >/dev/null 2>&1 || true; sleep 1; runuser -u steam -- env DISPLAY=:99 HOME=/home/steam XDG_RUNTIME_DIR=/tmp/xdg-steam TMPDIR=/home/steam/tmp LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 nohup bash -lc \"cd ${ROOT} && exec /usr/games/steam -gamepadui -fullscreen -no-cef-sandbox\" >/home/steam/steam-app.log 2>&1 < /dev/null &'"
|
||||
"bash -lc '/root/.config/sunshine/start-steam.sh'"
|
||||
],
|
||||
"prep-cmd": [
|
||||
{
|
||||
@@ -28,19 +28,6 @@
|
||||
}
|
||||
],
|
||||
"image-path": "desktop.png"
|
||||
},
|
||||
{
|
||||
"name": "Steam Manual Start",
|
||||
"detached": [
|
||||
"bash -lc 'id steam >/dev/null 2>&1 || useradd -m -s /bin/bash steam; ROOT=/home/steam/.local/share/Steam/debian-installation; mkdir -p ${ROOT} /tmp/xdg-steam /home/steam/tmp; ln -sfn /home/steam/.local/share/Steam /home/steam/.steam; chown -R steam:steam /home/steam /tmp/xdg-steam; pkill -u steam -f \"steam|steamwebhelper|steam-runtime\" >/dev/null 2>&1 || true; sleep 1; runuser -u steam -- env DISPLAY=:99 HOME=/home/steam XDG_RUNTIME_DIR=/tmp/xdg-steam TMPDIR=/home/steam/tmp LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 nohup bash -lc \"cd ${ROOT} && exec /usr/games/steam -gamepadui -fullscreen -no-cef-sandbox\" >/home/steam/steam-app.log 2>&1 < /dev/null &'"
|
||||
],
|
||||
"prep-cmd": [
|
||||
{
|
||||
"do": "",
|
||||
"undo": ""
|
||||
}
|
||||
],
|
||||
"image-path": "steam.png"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
47
players/p4_config/keep-steam-window.sh
Normal file
47
players/p4_config/keep-steam-window.sh
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/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
|
||||
118
players/p4_config/start-steam.sh
Normal file
118
players/p4_config/start-steam.sh
Normal file
@@ -0,0 +1,118 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
exec 9>/tmp/start-steam.lock
|
||||
flock -n 9 || exit 0
|
||||
|
||||
id steam >/dev/null 2>&1 || useradd -m -s /bin/bash steam
|
||||
STEAM_UID="$(id -u steam)"
|
||||
|
||||
ROOT=/home/steam/.local/share/Steam/debian-installation
|
||||
mkdir -p "${ROOT}" /tmp/xdg-steam /home/steam/tmp /run/dbus
|
||||
ln -sfn /home/steam/.local/share/Steam /home/steam/.steam
|
||||
chown -R steam:steam /home/steam /tmp/xdg-steam
|
||||
|
||||
ensure_dbus() {
|
||||
if ! dbus-send --system --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames >/dev/null 2>&1; then
|
||||
rm -f /run/dbus/pid
|
||||
dbus-daemon --system --fork >/dev/null 2>&1 || true
|
||||
fi
|
||||
}
|
||||
|
||||
ensure_fluxbox() {
|
||||
cp -f /etc/game-server/fluxbox/init /root/.fluxbox/init 2>/dev/null || true
|
||||
if ps -eo stat=,comm= 2>/dev/null | awk '$2=="fluxbox" && $1 !~ /Z/ { exit 0 } END { exit 1 }'; then
|
||||
FB="$(ps -eo pid=,stat=,comm= | awk '$3=="fluxbox" && $2 !~ /Z/ {print $1; exit}')"
|
||||
DISPLAY=:99 fluxbox-remote reloadconfig 2>/dev/null || kill -USR1 "${FB}" 2>/dev/null || true
|
||||
return 0
|
||||
fi
|
||||
DISPLAY=:99 HOME=/root fluxbox >/dev/null 2>&1 &
|
||||
sleep 1
|
||||
}
|
||||
|
||||
restart_fluxbox() {
|
||||
pkill -x fluxbox >/dev/null 2>&1 || true
|
||||
sleep 1
|
||||
cp -f /etc/game-server/fluxbox/init /root/.fluxbox/init 2>/dev/null || true
|
||||
DISPLAY=:99 HOME=/root fluxbox >/dev/null 2>&1 &
|
||||
sleep 1
|
||||
DISPLAY=:99 xsetroot -solid "#3c3c3c" 2>/dev/null || true
|
||||
}
|
||||
|
||||
steam_running() {
|
||||
pgrep -u steam -f "${ROOT}/ubuntu12_32/steam -srt-logger-opened" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
steam_ui_visible() {
|
||||
DISPLAY=:99 xwininfo -root -tree 2>/dev/null | grep -qE "Steam Big Picture Mode|Sign in to Steam"
|
||||
}
|
||||
|
||||
ensure_window_keeper() {
|
||||
command -v xdotool >/dev/null 2>&1 || return 0
|
||||
pgrep -f keep-steam-window.sh >/dev/null 2>&1 && return 0
|
||||
setsid bash /root/.config/sunshine/keep-steam-window.sh >/dev/null 2>&1 &
|
||||
}
|
||||
|
||||
schedule_gamepadui_once() {
|
||||
[ -f /tmp/steam-gamepadui-done ] && return 0
|
||||
setsid bash -lc '
|
||||
for _ in $(seq 1 90); do
|
||||
pgrep -u steam -f steamwebhelper >/dev/null 2>&1 && break
|
||||
sleep 1
|
||||
done
|
||||
sleep 5
|
||||
runuser -u steam -- env \
|
||||
DISPLAY=:99 \
|
||||
HOME=/home/steam \
|
||||
XDG_RUNTIME_DIR=/tmp/xdg-steam \
|
||||
TMPDIR=/home/steam/tmp \
|
||||
LANG=en_US.UTF-8 \
|
||||
LC_ALL=en_US.UTF-8 \
|
||||
/usr/games/steam steam://open/gamepadui >/dev/null 2>&1 || true
|
||||
touch /tmp/steam-gamepadui-done
|
||||
' >/dev/null 2>&1 &
|
||||
}
|
||||
|
||||
stop_steam() {
|
||||
pkill -9 -u steam -f "steam|steamwebhelper|steam-runtime|steam-runtime-launcher" >/dev/null 2>&1 || true
|
||||
pkill -f keep-steam-window.sh >/dev/null 2>&1 || true
|
||||
sleep 1
|
||||
rm -f /home/steam/.local/share/Steam/steam.pid \
|
||||
/home/steam/.local/share/Steam/steam.pipe \
|
||||
/home/steam/.local/share/Steam/steam.token \
|
||||
/tmp/steam-gamepadui-done
|
||||
rm -rf /home/steam/.local/share/Steam/debian-installation/config/htmlcache
|
||||
rm -rf /tmp/dumps/completed /tmp/dumps/*.lock 2>/dev/null || true
|
||||
rm -f /dev/shm/u"${STEAM_UID}"-* /dev/shm/u"${STEAM_UID}"-ValveIPC* /dev/shm/.org.chromium.* /dev/shm/pulse-* 2>/dev/null || true
|
||||
}
|
||||
|
||||
ensure_dbus
|
||||
restart_fluxbox
|
||||
|
||||
if steam_running; then
|
||||
if steam_ui_visible; then
|
||||
ensure_window_keeper
|
||||
exit 0
|
||||
fi
|
||||
schedule_gamepadui_once
|
||||
ensure_window_keeper
|
||||
exit 0
|
||||
fi
|
||||
|
||||
stop_steam
|
||||
ensure_dbus
|
||||
restart_fluxbox
|
||||
|
||||
setsid runuser -u steam -- env \
|
||||
DISPLAY=:99 \
|
||||
HOME=/home/steam \
|
||||
XDG_RUNTIME_DIR=/tmp/xdg-steam \
|
||||
TMPDIR=/home/steam/tmp \
|
||||
LANG=en_US.UTF-8 \
|
||||
LC_ALL=en_US.UTF-8 \
|
||||
bash -lc "cd ${ROOT} && exec /usr/games/steam -silent -no-cef-sandbox" \
|
||||
>>/home/steam/steam-app.log 2>&1 &
|
||||
|
||||
schedule_gamepadui_once
|
||||
ensure_window_keeper
|
||||
exit 0
|
||||
Reference in New Issue
Block a user