Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commandline: Flatten getIDFromTitle #1036

Merged
merged 2 commits into from
Jan 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 31 additions & 28 deletions steamtinkerlaunch
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
PREFIX="/usr"
PROGNAME="SteamTinkerLaunch"
NICEPROGNAME="Steam Tinker Launch"
PROGVERS="v14.0.20240129-2"
PROGVERS="v14.0.20240129-3"
PROGCMD="${0##*/}"
PROGINTERNALPROTNAME="Proton-stl"
SHOSTL="stl"
Expand Down Expand Up @@ -7805,38 +7805,41 @@ function listSteamGames {
function getIDFromTitle {
SEARCHSTEAMSHORTCUTS="${2:-0}" # Default to not searching Steam shortcuts
if [ -z "$1" ]; then
writelog "ERROR" "${FUNCNAME[0]} - No game title was provided to search on -- Nothing to do!"
echo "A Game Title (part of it might be enough) is required as argument"
else
# Check installed game appmanifests for name matches
FOUNDMATCHES=()

# Steam games
while read -r APPMA; do
APPMATITLE="$( getValueFromAppManifest "name" "$APPMA" )"
if [[ ${APPMATITLE,,} == *"${1,,}"* ]]; then
APPMAAID="$( basename "${APPMA%.*}" | cut -d '_' -f2 )"
FOUNDGAMNAM="$( printf "%s\t\t(%s)" "$APPMAAID" "$APPMATITLE" )" # Doing it this way makes tabs even for some reason
return 1
fi
# Check installed game appmanifests for name matches
FOUNDMATCHES=()

# Steam games
while read -r APPMA; do
APPMATITLE="$( getValueFromAppManifest "name" "$APPMA" )"
if [[ ${APPMATITLE,,} == *"${1,,}"* ]]; then
APPMAAID="$( basename "${APPMA%.*}" | cut -d '_' -f2 )"
FOUNDGAMNAM="$( printf "%s\t\t(%s)" "$APPMAAID" "$APPMATITLE" )" # Doing it this way makes tabs even for some reason
FOUNDMATCHES+=( "$FOUNDGAMNAM" )
fi
done <<< "$( listAppManifests )"

# Steam shortcuts
if [ "$SEARCHSTEAMSHORTCUTS" -eq "1" ] && haveAnySteamShortcuts ; then
while read -r SCVDFE; do
SVDFENAME="$( parseSteamShortcutEntryAppName "$SCVDFE" )"
SVDFEAID="$( parseSteamShortcutEntryAppID "$SCVDFE" )"

if [[ ${SVDFENAME,,} == *"${1,,}"* ]]; then
FOUNDGAMNAM="$( printf "%s\t\t(%s)" "$SVDFEAID" "$SVDFENAME" )"
FOUNDMATCHES+=( "$FOUNDGAMNAM" )
fi
done <<< "$( listAppManifests )"

# Steam shortcuts
if [ "$SEARCHSTEAMSHORTCUTS" -eq "1" ] && haveAnySteamShortcuts ; then
while read -r SCVDFE; do
SVDFENAME="$( parseSteamShortcutEntryAppName "$SCVDFE" )"
SVDFEAID="$( parseSteamShortcutEntryAppID "$SCVDFE" )"
done <<< "$( getSteamShortcutHex )"
fi

if [[ ${SVDFENAME,,} == *"${1,,}"* ]]; then
FOUNDGAMNAM="$( printf "%s\t\t(%s)" "$SVDFEAID" "$SVDFENAME" )"
FOUNDMATCHES+=( "$FOUNDGAMNAM" )
fi
done <<< "$( getSteamShortcutHex )"
fi
if [ "${#FOUNDMATCHES[@]}" -gt 0 ]; then
printf "%s\n" "${FOUNDMATCHES[@]}"
else
echo "Could not find AppID for name '$1'."
fi
if [ "${#FOUNDMATCHES[@]}" -gt 0 ]; then
printf "%s\n" "${FOUNDMATCHES[@]}"
else
echo "Could not find AppID for name '$1'."
fi
}

Expand Down