feat(steam): first-run defaults for big art and the bouncing logo screensaver (#3087)

* feat(steam): first-run defaults for big art on Library home and the bouncing logo screensaver

* fix(steam): seeded keys land in the root store when nested stores close on its last line
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-23 14:16:51 -05:00
1 parent 86ad1544a6
commit e3b1b60914
4 files changed
+55 -4

No files matched your search

@@ -660,6 +660,7 @@ object SessionFiles {
private const val UI_STATE = "UIStoreLocalSteamUIState"
private const val SORT_RECENT_OFF = "\\\"bSortedByRecent\\\":false"
private const val SORT_RECENT_ON = "\\\"bSortedByRecent\\\":true"
private const val LIBRARY_BIG_ART = "LibraryHomeBigArt"
private const val BATTERY_PERCENT_ON = "{\\\"bShowBatteryPercentage\\\":true}"
/**
@@ -709,7 +710,12 @@ object SessionFiles {
val block = out.substring(web.keyStart, web.close + 1)
out = out.replaceRange(web.keyStart, web.close + 1, setScalar(block, BATTERY_PREFERENCES, BATTERY_PERCENT_ON, newline))
}
return seedRecentSort(out, newline)
out = seedRecentSort(out, newline)
val last = findObject(out, "UserLocalConfigStore", 0, out.length) ?: return out
if (!hasKey(out.substring(last.open + 1, last.close), LIBRARY_BIG_ART)) {
out = insertInto(out, last, listOf("\"$LIBRARY_BIG_ART\"\t\t\"1\""), newline)
}
return out
}
// The library sort lives inside a JSON string; Steam writes bSortedByRecent:false until the player picks a sort,
@@ -729,9 +735,11 @@ object SessionFiles {
private fun insertInto(text: String, parent: VdfBlock, lines: List<String>, newline: String): String {
val lineStart = text.lastIndexOf('\n', parent.close).let { if (it < 0) 0 else it + 1 }
val indent = text.substring(lineStart, parent.close).takeWhile { it == '\t' || it == ' ' } + "\t"
val before = text.substring(lineStart, parent.close)
val indent = before.takeWhile { it == '\t' || it == ' ' } + "\t"
val section = lines.joinToString(newline) { indent + it } + newline
return text.substring(0, lineStart) + section + text.substring(lineStart)
if (before.isBlank()) return text.substring(0, lineStart) + section + text.substring(lineStart)
return text.substring(0, parent.close) + newline + section + text.substring(parent.close)
}
private val IDLE_SLEEP_TIMERS = listOf("IdleSuspendBatterySeconds", "IdleSuspendACSeconds")
@@ -59,6 +59,27 @@ class SteamUserDefaultsTest {
assertFalse(File(home, "userdata/123/config/droiddeck-user-defaults-initialized").exists())
}
@Test fun libraryHomeUsesBigArtUnlessChosenOtherwise() {
val fresh = home("")
SessionFiles.seedUserDefaults(fresh)
assertTrue(text(fresh).contains("\"LibraryHomeBigArt\"\t\t\"1\""))
val chosen = home("\t\"LibraryHomeBigArt\"\t\t\"0\"\n")
SessionFiles.seedUserDefaults(chosen)
assertTrue(text(chosen).contains("\"LibraryHomeBigArt\"\t\t\"0\""))
assertEquals(1, Regex("LibraryHomeBigArt").findAll(text(chosen)).count())
}
@Test fun bigArtLandsInTheRootWhenNestedStoresCloseOnItsLastLine() {
val home = home("")
File(home, "userdata/123/config/localconfig.vdf").writeText(
"\"UserLocalConfigStore\"\n{\n\t\"WebStorage\"\n\t{\n\t\t\"Other\"\t\t\"x\"\n\t}}\n")
SessionFiles.seedUserDefaults(home)
val t = text(home)
val beforeBigArt = t.substring(0, t.indexOf("\"LibraryHomeBigArt\""))
assertEquals(beforeBigArt.count { it == '{' }, beforeBigArt.count { it == '}' } + 1)
assertTrue(t.indexOf("\"CachedBatteryPreferences\"") < t.indexOf("\"LibraryHomeBigArt\""))
}
@Test fun librarySortsByRecentlyPlayed() {
val fresh = home("")
SessionFiles.seedUserDefaults(fresh)