Skip to content

Commit ae7f75a

Browse files
authored
Commandline: Add command to remove per-game grids and all game grids (#957)
1 parent 87bb53a commit ae7f75a

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

steamtinkerlaunch

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
PREFIX="/usr"
77
PROGNAME="SteamTinkerLaunch"
88
NICEPROGNAME="Steam Tinker Launch"
9-
PROGVERS="v14.0.20231024-1"
9+
PROGVERS="v14.0.20231024-2"
1010
PROGCMD="${0##*/}"
1111
PROGINTERNALPROTNAME="Proton-stl"
1212
SHOSTL="stl"
@@ -1391,6 +1391,7 @@ function checkSGDbApi {
13911391
## Generic function to fetch some artwork from SteamGridDB based on an endpoint
13921392
## TODO: Steam only officially supports PNGs, test to see if WebP works when manually copied, and if it doesn't, we should try to only download PNG files
13931393
## TODO: Add max filesize option? Some artworks are really big, we should skip ones that are too large (though this may mean many animated APNG artworks will get skipped, because APNG can be huge)
1394+
## TODO: Retry/Timeout when fetching artwork
13941395
function downloadArtFromSteamGridDB {
13951396
if checkSGDbApi && [ "$STLPLAY" -eq 0 ]; then
13961397
# Required
@@ -1668,6 +1669,32 @@ function getSGDBGameIDFromTitle {
16681669
fi
16691670
}
16701671

1672+
# Remove artwork for single game based on AppID, or all grids
1673+
function removeSteamGrids {
1674+
RMGAMEGRID="${1,,}" # Should be Steam AppID or "all"
1675+
SGGRIDDIR="${STUIDPATH}/config/grid"
1676+
1677+
if [ -z "$1" ]; then
1678+
writelog "ERROR" "${FUNCNAME[0]} - No parameter given, cannot remove artwork, skipping"
1679+
echo "You must provide either a Steam AppID to remove artwork for, or specify 'all' to remove all game artwork"
1680+
fi
1681+
1682+
if [ "$1" == "all" ]; then
1683+
writelog "INFO" "${FUNCNAME[0]} - Removing grid artwork for all Steam games"
1684+
rmDirIfExists "${SGGRIDDIR}"
1685+
mkdir "${SGGRIDDIR}"
1686+
else
1687+
# Find any grid artwork for AppID -- Have to use find and use it on each artwork name because we don't want to match AppIDs which contain other AppIDs
1688+
# i.e. searching for '140*' would return matches with '1402750' as well
1689+
writelog "INFO" "${FUNCNAME[0]} - Removing any grid artwork for game with AppID '$1'"
1690+
find "${SGGRIDDIR}" -name "${RMGAMEGRID}_hero.*" -exec rm {} \; # Hero
1691+
find "${SGGRIDDIR}" -name "${RMGAMEGRID}_logo.*" -exec rm {} \; # Logo
1692+
find "${SGGRIDDIR}" -name "${RMGAMEGRID}p.*" -exec rm {} \; # Boxart
1693+
find "${SGGRIDDIR}" -name "${RMGAMEGRID}.*" -exec rm {} \; # Tenfoot
1694+
find "${SGGRIDDIR}" -name "${RMGAMEGRID}_icon.*" -exec rm {} \; # Icon (custom STL name for Non-Steam Games)
1695+
fi
1696+
}
1697+
16711698
function getDataForAllGamesinSharedConfig {
16721699
while read -r CATAID; do
16731700
getGameData "$CATAID"
@@ -21276,6 +21303,20 @@ function getDefaultProton {
2127621303
fi
2127721304
}
2127821305

21306+
function rmFileIfExists {
21307+
if [ -f "$1" ]; then
21308+
writelog "INFO" "${FUNCNAME[0]} - Removing '$1'"
21309+
rm "$1"
21310+
fi
21311+
}
21312+
21313+
function rmDirIfExists {
21314+
if [ -d "$1" ]; then
21315+
writelog "INFO" "${FUNCNAME[0]} - Removing '$1'"
21316+
rm -rf "$1"
21317+
fi
21318+
}
21319+
2127921320
function FUSEID {
2128021321
if [ -n "$1" ]; then
2128121322
USEID="$1"
@@ -21353,6 +21394,9 @@ function howto {
2135321394
echo " (for 'SteamAppID' or 'all')"
2135421395
echo " block Opens the category Block selection menu"
2135521396
echo " cleardeckdeps Remove downloaded Steam Deck dependencies, allowing them to"
21397+
echo " cleargamegrids <arg> Remove downloaded game grids based on <arg>, which should be one of the following"
21398+
echo " <appid> Remove artwork for game with specific AppID, ex: 787480"
21399+
echo " all Remove ALL grid artwork by removing entire Steam Grids folder"
2135621400
echo " update on next launch (This option is only applicable to SteamOS 3.X)"
2135721401
echo " compat <cmd> Will (add|del|get) ${PROGNAME,,} as"
2135821402
echo " Steam compatibility tool"
@@ -22122,6 +22166,13 @@ function commandline {
2212222166
else
2212322167
howto
2212422168
fi
22169+
elif [ "$1" == "cleargamegrids" ]; then
22170+
if [ -z "$2" ]; then
22171+
writelog "ERROR" "${FUNCNAME[0]} - No parameter given, cannot remove artwork, skipping"
22172+
echo "You must provide either a Steam AppID to remove artwork for, or specify 'all' to remove all game artwork"
22173+
else
22174+
removeSteamGrids "$2"
22175+
fi
2212522176
elif [ "$1" == "version" ] || [ "$1" == "--version" ] || [ "$1" == "-v" ]; then
2212622177
echo "${PROGNAME,,}-${PROGVERS}"
2212722178
elif [ "$1" == "$VTX" ]; then

0 commit comments

Comments
 (0)