b4f4fe2f07
- Removed obsolete launch_desktop.sh and launch_session.sh scripts. - Introduced new steam-launcher script to handle Steam launching and session tracking. - Added steam-short-session-tracker for monitoring short Steam sessions and triggering repairs. - Created steamos and steamos-session scripts for managing the SteamOS session. - Implemented steamos-session-select for switching between Gamescope and Plasma sessions. - Updated SDDM configuration for autologin and session management. - Added new systemd services and targets for managing Gamescope and Steam sessions. - Created desktop entries and icons for ALVR and SteamOS shortcuts. - Enhanced logging and error handling across scripts. - Cleaned up unused systemd slice and service files. - Updated Ansible playbook to reflect new configurations and file structures.
77 lines
2.7 KiB
Bash
77 lines
2.7 KiB
Bash
#!/bin/bash
|
|
|
|
short_session_tracker_file="/tmp/steamos-short-session-tracker"
|
|
short_session_start_file="/tmp/steamos-short-session-start"
|
|
short_session_duration=60
|
|
short_session_count_before_reset=3
|
|
|
|
do_repair() {
|
|
# This should really be part of the steam launcher as `steam --repair` or similar, but we presently only have
|
|
# `steam --reset` which is too heavy of a hammer.
|
|
|
|
echo >&2 "steam-short-session-tracker: Re-bootstrapping steam from OS copy."
|
|
# at this point, might as well make sure we won't relaunch on a sideloaded build
|
|
rm -f -- "$HOME/devkit-game/devkit-steam"
|
|
mkdir -p ~/.local/share/Steam
|
|
# remove some caches and stateful things known to cause Steam to fail to start if corrupt
|
|
rm -rf --one-file-system ~/.local/share/Steam/config/widevine
|
|
# cleanup the steam config dir, i.e. ~/.steam. We should try to preserve registry.vdf if possible
|
|
steam_config_dir="$HOME/.steam"
|
|
steam_config_backup_dir="$HOME/dot-steam.bak.$(date +%s)"
|
|
registry_vdf="$steam_config_dir/registry.vdf"
|
|
registry_backup_vdf="$steam_config_backup_dir/.steam/registry.vdf"
|
|
mv "$steam_config_dir" "$steam_config_backup_dir"
|
|
mkdir -p "$steam_config_dir"
|
|
cp -f "$registry_backup_vdf" "$registry_vdf" || true
|
|
# restore clean copy of binaries from RO partition
|
|
tar xf /usr/lib/steam/bootstraplinux_ubuntu12_32.tar.xz -C ~/.local/share/Steam
|
|
# rearm
|
|
rm "$short_session_tracker_file"
|
|
}
|
|
|
|
handle_started() {
|
|
short_session_count=$(< "$short_session_tracker_file" wc -l)
|
|
touch $short_session_start_file
|
|
|
|
if [[ "$short_session_count" -ge "$short_session_count_before_reset" ]]; then
|
|
echo >&2 "steam-short-session-tracker: Steam failed to start $short_session_count_before_reset times within $short_session_duration seconds"
|
|
|
|
if [ -f "$HOME/.config/inhibit-short-session-tracker" ]; then
|
|
echo >&2 "steam-short-session-tracker: Auto-repair disabled by config. Remove ~/.config/inhibit-short-session-tracker to re-enable"
|
|
return
|
|
fi
|
|
|
|
do_repair
|
|
fi
|
|
}
|
|
|
|
handle_stopped() {
|
|
seconds_since_started=$(($(date +%s) - $(date +%s -r "$short_session_start_file")))
|
|
|
|
if [[ "seconds_since_started" -lt "$short_session_duration" ]]; then
|
|
echo "frog" >> "$short_session_tracker_file"
|
|
else
|
|
rm "$short_session_tracker_file"
|
|
fi
|
|
}
|
|
|
|
case "$1" in
|
|
--track-started)
|
|
echo "steam-short-session-tracker: Tracking Steam start (unimplemented)"
|
|
# handle_started
|
|
;;
|
|
--track-stopped)
|
|
echo "steam-short-session-tracker: Tracking Steam stop (unimplemented)"
|
|
# handle_stopped
|
|
;;
|
|
--repair-now)
|
|
echo "steam-short-session-tracker: Performing immediate repair (unimplemented)"
|
|
# do_repair
|
|
;;
|
|
*)
|
|
echo "Usage: $0 --track-started | --track-stopped | --repair-now"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
exit 0 |