mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-25 15:56:01 +00:00
fix: find the signed-in Steam account when loginusers.vdf has no MostRecent
droiddeck-steam-shortcuts and AddedGames.accountConfig took the account
marked "MostRecent" in loginusers.vdf, else the only userdata folder.
The arm64 client here writes no MostRecent, so with two accounts in one
install nothing was picked: no added or store game reached
shortcuts.vdf ("no signed-in account yet; nothing written") and Steam
answered their launch with "App configuration unavailable".
Without MostRecent, take the account marked AutoLogin, then the one with
the latest timestamp. Both sides use the same order so the app reads the
config the guest script writes.
This commit is contained in:
1 parent
473ac666b3
commit
8c86b718a0
4 files changed
+86
-7
No files matched your search
@@ -16,15 +16,20 @@ TAG = "droiddeck-app"
|
||||
|
||||
|
||||
def account_dir(steam_root):
|
||||
"""The most recent account's userdata folder, else the only one that is not 0."""
|
||||
"""The signed-in account's userdata folder, else the only one that is not 0. Clients that do not
|
||||
write MostRecent still mark that account AutoLogin; the latest timestamp breaks the remaining ties."""
|
||||
users = os.path.join(steam_root, "config", "loginusers.vdf")
|
||||
recent = None
|
||||
recent, best = None, None
|
||||
try:
|
||||
with open(users, encoding="utf-8", errors="replace") as f:
|
||||
text = f.read()
|
||||
for block in re.finditer(r'"(\d{5,})"\s*\{([^}]*)\}', text):
|
||||
if re.search(r'"MostRecent"\s*"1"', block.group(2)):
|
||||
recent = int(block.group(1))
|
||||
stamp = re.search(r'"timestamp"\s*"(\d+)"', block.group(2))
|
||||
rank = (bool(re.search(r'"MostRecent"\s*"1"', block.group(2))),
|
||||
bool(re.search(r'"AutoLogin"\s*"1"', block.group(2))),
|
||||
int(stamp.group(1)) if stamp else 0)
|
||||
if any(rank) and (best is None or rank >= best):
|
||||
recent, best = int(block.group(1)), rank
|
||||
except OSError:
|
||||
pass
|
||||
userdata = os.path.join(steam_root, "userdata")
|
||||
|
||||
@@ -203,6 +203,30 @@ class ShortcutsTest(unittest.TestCase):
|
||||
self.assertEqual('-vulkan', steam['LaunchOptions'])
|
||||
self.assertEqual('Mine', steam['AppName'])
|
||||
|
||||
def users(self, *blocks):
|
||||
body = ''.join('\t"%d"\n\t{\n%s\t}\n' % (76561197960265728 + acct, ''.join('\t\t"%s"\t\t"%s"\n' % kv for kv in keys.items()))
|
||||
for acct, keys in blocks)
|
||||
(self.steam / 'config').mkdir(exist_ok=True)
|
||||
(self.steam / 'config/loginusers.vdf').write_text('"users"\n{\n%s}\n' % body)
|
||||
(self.steam / 'userdata/456/config').mkdir(parents=True, exist_ok=True)
|
||||
|
||||
def test_the_account_marked_most_recent_is_used(self):
|
||||
self.users((123, dict(MostRecent='1', AutoLogin='0', timestamp='100')), (456, dict(MostRecent='0', AutoLogin='1', timestamp='200')))
|
||||
self.assertEqual(str(self.steam / 'userdata/123'), shortcuts.account_dir(str(self.steam)))
|
||||
|
||||
def test_without_most_recent_the_account_that_signs_in_is_used(self):
|
||||
self.users((123, dict(AutoLogin='1', timestamp='100')), (456, dict(AutoLogin='0', timestamp='200')))
|
||||
self.assertEqual(str(self.steam / 'userdata/123'), shortcuts.account_dir(str(self.steam)))
|
||||
self.assertIn(APPID, self.run_writer(self.game()))
|
||||
|
||||
def test_without_either_mark_the_account_used_last_is_used(self):
|
||||
self.users((456, dict(AutoLogin='0', timestamp='100')), (123, dict(AutoLogin='0', timestamp='200')))
|
||||
self.assertEqual(str(self.steam / 'userdata/123'), shortcuts.account_dir(str(self.steam)))
|
||||
|
||||
def test_two_accounts_without_any_mark_write_nothing(self):
|
||||
self.users((123, dict(AccountName='a')), (456, dict(AccountName='b')))
|
||||
self.assertIsNone(shortcuts.account_dir(str(self.steam)))
|
||||
|
||||
def test_an_older_record_without_launch_options_still_takes_the_apps(self):
|
||||
self.run_writer(self.game())
|
||||
record = self.record()
|
||||
|
||||
Reference in new issue
Block a user