mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
Keep waiting for a shortcut's Steam overview instead of dropping its cold launch (#914)
fix: keep waiting for a shortcut's Steam overview instead of dropping its launch The cold-launch gate waited once for 45 s and, on a timeout, held the launch URL for good. A library that loads slower than that (or a client still at the sign-in screen) left the requested game never started, with nothing on screen. Retry the wait up to 40 times, 45 s each, and launch as soon as the overview exists. The no-overview case still does not forward the CGameID. Co-authored-by: ovurrsl <ovurrsl@users.noreply.github.com>
This commit is contained in:
1 parent
dce7e7ece6
commit
a422698f92
2 files changed
+41
-12
No files matched your search
@@ -545,18 +545,31 @@ case $mode in
|
||||
until [ "$(xprop -root GAMESCOPE_FOCUSED_APP 2>/dev/null | sed -n 's/.*= *//p')" = 769 ] || [ "$SECONDS" -ge "$_bl_end" ]; do
|
||||
sleep 1
|
||||
done
|
||||
if /usr/local/bin/droiddeck-agent --wait-steam-shortcut-overview "$_bl_held" 45; then
|
||||
# A large library can take longer than one 45 s wait to load.
|
||||
_bl_overview_status=1
|
||||
_bl_overview_tries=0
|
||||
while [ "$_bl_overview_tries" -lt 40 ]; do
|
||||
if /usr/local/bin/droiddeck-agent --wait-steam-shortcut-overview "$_bl_held" 45; then
|
||||
_bl_overview_status=0
|
||||
else
|
||||
_bl_overview_status=$?
|
||||
fi
|
||||
if [ "$_bl_overview_status" -ne 1 ]; then
|
||||
break
|
||||
fi
|
||||
_bl_overview_tries=$((_bl_overview_tries + 1))
|
||||
echo "== steam: shortcut overview not ready yet; Steam may still be loading the library (attempt $_bl_overview_tries of 40)"
|
||||
sleep 2
|
||||
done
|
||||
if [ "$_bl_overview_status" -eq 0 ]; then
|
||||
echo "== steam: shortcut overview ready; launching the requested game $_bl_held"
|
||||
_bl_launch_ready=1
|
||||
elif [ "$_bl_overview_status" -eq 3 ]; then
|
||||
echo "== steam: not a shortcut CGameID; keeping the existing launch path"
|
||||
sleep 4
|
||||
_bl_launch_ready=1
|
||||
else
|
||||
_bl_overview_status=$?
|
||||
if [ "$_bl_overview_status" -eq 3 ]; then
|
||||
echo "== steam: not a shortcut CGameID; keeping the existing launch path"
|
||||
sleep 4
|
||||
_bl_launch_ready=1
|
||||
else
|
||||
echo "== steam: expected shortcut overview did not become ready; holding the launch URL"
|
||||
fi
|
||||
echo "== steam: expected shortcut overview did not become ready; holding the launch URL"
|
||||
fi
|
||||
if [ "$_bl_launch_ready" = 1 ]; then
|
||||
echo "== steam: interface up; launching the requested game $_bl_held"
|
||||
|
||||
@@ -32,12 +32,19 @@ class SteamColdLaunchTest(unittest.TestCase):
|
||||
self.bin.mkdir()
|
||||
self.agent_args = self.root / "agent-args"
|
||||
self.sleep_args = self.root / "sleep-args"
|
||||
self.agent_count = self.root / "agent-count"
|
||||
|
||||
xprop = self.bin / "xprop"
|
||||
xprop.write_text("#!/bin/sh\necho 'GAMESCOPE_FOCUSED_APP(CARDINAL) = 769'\n")
|
||||
xprop.chmod(0o755)
|
||||
agent = self.bin / "droiddeck-agent"
|
||||
agent.write_text("#!/bin/sh\nprintf '%s\\n' \"$@\" > \"$AGENT_ARGS\"\nexit \"$AGENT_STATUS\"\n")
|
||||
agent.write_text(
|
||||
"#!/bin/sh\n"
|
||||
"printf '%s\\n' \"$@\" > \"$AGENT_ARGS\"\n"
|
||||
"n=$(cat \"$AGENT_COUNT\" 2>/dev/null || echo 0); n=$((n + 1)); echo $n > \"$AGENT_COUNT\"\n"
|
||||
"i=0; last=1\n"
|
||||
"for s in $AGENT_STATUS; do i=$((i + 1)); last=$s; [ \"$i\" -eq \"$n\" ] && exit \"$s\"; done\n"
|
||||
"exit \"$last\"\n")
|
||||
agent.chmod(0o755)
|
||||
sleep = self.bin / "sleep"
|
||||
sleep.write_text("#!/bin/sh\nprintf '%s\\n' \"$@\" >> \"$SLEEP_ARGS\"\n")
|
||||
@@ -48,7 +55,7 @@ class SteamColdLaunchTest(unittest.TestCase):
|
||||
env = dict(os.environ, HOME=str(self.root), BL_LAUNCH_DIR=str(self.launch_dir),
|
||||
PATH=str(self.bin) + os.pathsep + os.environ["PATH"],
|
||||
AGENT_ARGS=str(self.agent_args), SLEEP_ARGS=str(self.sleep_args),
|
||||
AGENT_STATUS=str(helper_status))
|
||||
AGENT_COUNT=str(self.agent_count), AGENT_STATUS=str(helper_status))
|
||||
script = self.block + "\nprintf 'ARG:%s\\n' \"$@\"\nwait\n"
|
||||
url = target if target.startswith("steam://") else "steam://rungameid/" + target
|
||||
result = subprocess.run(["bash", "-c", script, "cold-launch", url],
|
||||
@@ -76,7 +83,16 @@ class SteamColdLaunchTest(unittest.TestCase):
|
||||
result = self.run_launch(game_id, 1)
|
||||
self.assertFalse((self.launch_dir / "steam-game").exists(), result.stdout)
|
||||
self.assertEqual(["--wait-steam-shortcut-overview", game_id, "45"], self.agent_args.read_text().splitlines())
|
||||
self.assertFalse(self.sleep_args.exists())
|
||||
self.assertEqual("40", self.agent_count.read_text().strip())
|
||||
self.assertEqual(["2"] * 40, self.sleep_args.read_text().split())
|
||||
|
||||
def test_a_slow_steam_library_still_gets_its_game_launched(self):
|
||||
game_id = str((3551182975 << 32) | 0x02000000)
|
||||
result = self.run_launch(game_id, "1 1 1 0")
|
||||
self.assertEqual(game_id, (self.launch_dir / "steam-game").read_text().strip(), result.stdout)
|
||||
self.assertEqual("4", self.agent_count.read_text().strip())
|
||||
self.assertEqual(["2", "2", "2"], self.sleep_args.read_text().split())
|
||||
self.assertIn("attempt 3 of 40", result.stdout)
|
||||
|
||||
def test_non_game_steam_urls_remain_on_the_original_startup_arguments(self):
|
||||
url = "steam://open/library"
|
||||
|
||||
Reference in new issue
Block a user