fix: keep hidden and private Steam games off the Steam home art wall (#1097)

This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-10-18 19:11:30 -04:00
1 parent 8baa16073f
commit e10fc86a76
2 files changed
+71 -2

No files matched your search

@@ -72,6 +72,7 @@ object Library {
private val NAME = Regex("^\\s*\"name\"\\s*\"([^\"]*)\"", RegexOption.MULTILINE)
private val STATE = Regex("^\\s*\"StateFlags\"\\s*\"(\\d+)\"", RegexOption.MULTILINE)
private val LAST_PLAYED = Regex("^\\s*\"LastPlayed\"\\s*\"(\\d+)\"", RegexOption.MULTILINE)
private val PRIVATE_APPS = Regex("\"PrivateApps_\\d+\"\\s*\"\\[([^\\]]*)\\]\"")
private val INSTALL_DIR = Regex("^\\s*\"installdir\"\\s*\"([^\"]*)\"", RegexOption.MULTILINE)
internal fun steamLibraries(context: Context, arch: String = SessionPrefs.activeSteamClientArch(context)): List<Pair<File, String>> {
@@ -137,13 +138,35 @@ object Library {
}
fun steamLibraryArt(context: Context): List<Pair<Int, File>> {
val cache = File(SessionPrefs.activeSteamRoot(context), "appcache/librarycache")
val root = SessionPrefs.activeSteamRoot(context)
val cache = File(root, "appcache/librarycache")
val concealed = concealedSteamApps(root)
return cache.listFiles().orEmpty().mapNotNull { dir ->
val appId = dir.name.toIntOrNull()?.takeIf { it !in NOT_GAMES } ?: return@mapNotNull null
val appId = dir.name.toIntOrNull()?.takeIf { it !in NOT_GAMES && it.toLong() !in concealed } ?: return@mapNotNull null
steamCacheImage(cache, appId, STEAM_CAPSULES)?.let { appId to it }
}
}
/** Apps the user hid (the "hidden" collection) or marked private in Steam. */
internal fun concealedSteamApps(root: File): Set<Long> {
val config = AddedGames.accountConfig(root) ?: return emptySet()
val hidden = runCatching {
val entries = org.json.JSONArray(File(config, "cloudstorage/cloud-storage-namespace-1.json").readText())
val entry = (0 until entries.length()).map { entries.getJSONArray(it) }
.firstOrNull { it.optString(0) == "user-collections.hidden" }?.optJSONObject(1)
if (entry == null || entry.optBoolean("is_deleted")) emptySet() else {
val collection = org.json.JSONObject(entry.optString("value"))
fun ids(key: String) = collection.optJSONArray(key)?.let { a -> (0 until a.length()).map { a.optLong(it) } }.orEmpty()
ids("added").toSet() - ids("removed").toSet()
}
}.getOrDefault(emptySet())
val private = runCatching {
PRIVATE_APPS.find(File(config, "localconfig.vdf").readText())?.groupValues?.get(1)
?.split(',')?.mapNotNull { it.trim().toLongOrNull() }?.toSet()
}.getOrNull().orEmpty()
return hidden + private
}
fun fromSteamClient(g: SteamGame): Boolean = g.library != ADDED && g.source == SOURCE_STEAM
fun launchableGames(
@@ -0,0 +1,46 @@
package com.droiddeck.launcher.frontend
import java.io.File
import org.junit.Assert.assertEquals
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [33])
class LibraryConcealedAppsTest {
@get:Rule val tmp = TemporaryFolder()
private fun steamRoot(): File = tmp.newFolder("Steam").also { root ->
File(root, "config").mkdirs()
File(root, "config/loginusers.vdf").writeText(
"\"users\"\n{\n\t\"76561198352563669\"\n\t{\n\t\t\"AccountName\"\t\t\"a\"\n\t\t\"MostRecent\"\t\t\"1\"\n\t}\n}\n")
}
private fun config(root: File) = File(root, "userdata/392297941/config").apply { mkdirs() }
@Test fun hiddenCollectionAndPrivateAppsAreBothConcealed() {
val root = steamRoot()
val config = config(root)
File(config, "cloudstorage").mkdirs()
File(config, "cloudstorage/cloud-storage-namespace-1.json").writeText(
"""[["user-collections.favorite",{"key":"user-collections.favorite","value":"{\"id\":\"favorite\",\"added\":[620],\"removed\":[]}"}],""" +
"""["user-collections.hidden",{"key":"user-collections.hidden","value":"{\"id\":\"hidden\",\"name\":\"Hidden\",\"added\":[223470,2931908220,400],\"removed\":[400]}"}]]""")
File(config, "localconfig.vdf").writeText(
"\"UserLocalConfigStore\"\n{\n\t\"WebStorage\"\n\t{\n\t\t\"PrivateApps_392297941\"\t\t\"[339800,567090]\"\n\t}\n}\n")
assertEquals(setOf(223470L, 2931908220L, 339800L, 567090L), Library.concealedSteamApps(root))
}
@Test fun deletedHiddenCollectionAndMissingFilesConcealNothing() {
val root = steamRoot()
assertEquals(emptySet<Long>(), Library.concealedSteamApps(root))
val config = config(root)
File(config, "cloudstorage").mkdirs()
File(config, "cloudstorage/cloud-storage-namespace-1.json").writeText(
"""[["user-collections.hidden",{"key":"user-collections.hidden","is_deleted":true}]]""")
assertEquals(emptySet<Long>(), Library.concealedSteamApps(root))
}
}