mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 13:26:02 +00:00
Launch an added game after a bounded wait for its Steam overview (#973)
This commit is contained in:
1 parent
62192203e9
commit
9c9486400b
2 files changed
+26
-16
No files matched your search
@@ -545,10 +545,10 @@ 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
|
||||
# A large library can take longer than one 45 s wait to load.
|
||||
# With a large library the overview can stay missing for 30+ minutes while Steam already takes the launch URL.
|
||||
_bl_overview_status=1
|
||||
_bl_overview_tries=0
|
||||
while [ "$_bl_overview_tries" -lt 40 ]; do
|
||||
while [ "$_bl_overview_tries" -lt 2 ]; do
|
||||
if /usr/local/bin/droiddeck-agent --wait-steam-shortcut-overview "$_bl_held" 45; then
|
||||
_bl_overview_status=0
|
||||
else
|
||||
@@ -558,7 +558,7 @@ case $mode in
|
||||
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)"
|
||||
echo "== steam: shortcut overview not ready yet (attempt $_bl_overview_tries of 2)"
|
||||
sleep 2
|
||||
done
|
||||
if [ "$_bl_overview_status" -eq 0 ]; then
|
||||
@@ -569,7 +569,8 @@ case $mode in
|
||||
sleep 4
|
||||
_bl_launch_ready=1
|
||||
else
|
||||
echo "== steam: expected shortcut overview did not become ready; holding the launch URL"
|
||||
echo "== steam: shortcut overview not ready after about 90 s; launching the requested game anyway $_bl_held"
|
||||
_bl_launch_ready=1
|
||||
fi
|
||||
if [ "$_bl_launch_ready" = 1 ]; then
|
||||
echo "== steam: interface up; launching the requested game $_bl_held"
|
||||
|
||||
@@ -78,21 +78,30 @@ class SteamColdLaunchTest(unittest.TestCase):
|
||||
self.assertEqual(["--wait-steam-shortcut-overview", game_id, "45"], self.agent_args.read_text().splitlines())
|
||||
self.assertEqual("4", self.sleep_args.read_text().strip())
|
||||
|
||||
def test_shortcut_without_the_expected_overview_does_not_forward_cgameid(self):
|
||||
def test_a_shortcut_whose_overview_never_appears_is_launched_after_a_bounded_wait(self):
|
||||
game_id = str((3551182975 << 32) | 0x02000000)
|
||||
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.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)
|
||||
self.assertEqual(["--wait-steam-shortcut-overview", game_id, "45"], self.agent_args.read_text().splitlines())
|
||||
self.assertEqual("2", self.agent_count.read_text().strip())
|
||||
self.assertEqual(["2", "2"], self.sleep_args.read_text().split())
|
||||
self.assertIn("launching the requested game anyway", result.stdout)
|
||||
|
||||
def test_a_late_overview_is_still_waited_for_once_more(self):
|
||||
game_id = str((3551182975 << 32) | 0x02000000)
|
||||
result = self.run_launch(game_id, "1 0")
|
||||
self.assertEqual(game_id, (self.launch_dir / "steam-game").read_text().strip(), result.stdout)
|
||||
self.assertEqual("2", self.agent_count.read_text().strip())
|
||||
self.assertEqual(["2"], self.sleep_args.read_text().split())
|
||||
self.assertIn("attempt 1 of 2", result.stdout)
|
||||
self.assertNotIn("anyway", result.stdout)
|
||||
|
||||
def test_an_agent_failure_other_than_a_timeout_launches_without_retrying(self):
|
||||
game_id = str((3551182975 << 32) | 0x02000000)
|
||||
result = self.run_launch(game_id, 2)
|
||||
self.assertEqual(game_id, (self.launch_dir / "steam-game").read_text().strip(), result.stdout)
|
||||
self.assertEqual("1", self.agent_count.read_text().strip())
|
||||
self.assertFalse(self.sleep_args.exists())
|
||||
|
||||
def test_non_game_steam_urls_remain_on_the_original_startup_arguments(self):
|
||||
url = "steam://open/library"
|
||||
|
||||
Reference in new issue
Block a user