Commit d21849c1 authored by Alex Smith's avatar Alex Smith

support appid as name on listSteamGames

Добавил поддержку игр у которых вместо названия используется SteamAppId Для них appid берется из названии игры, а name из имени скрипта
parent 1d2ac06f
...@@ -225,36 +225,47 @@ listInstalledSteamGames() { ...@@ -225,36 +225,47 @@ listInstalledSteamGames() {
} }
listNonSteamGames() { listNonSteamGames() {
getSteamShortcutHex | while read -r SCVDFE; do getSteamShortcutHex | while read -r SCVDFE; do
jq -n \ jq -n \
--arg id "$(parseSteamShortcutEntryAppID "${SCVDFE}")" \ --arg id "$(parseSteamShortcutEntryAppID "${SCVDFE}")" \
--arg name "$(parseSteamShortcutEntryAppName "${SCVDFE}")" \ --arg name "$(parseSteamShortcutEntryAppName "${SCVDFE}")" \
--arg exe "$(parseSteamShortcutEntryExe "${SCVDFE}")" \ --arg exe "$(parseSteamShortcutEntryExe "${SCVDFE}")" \
--arg dir "$(parseSteamShortcutEntryStartDir "${SCVDFE}")" \ --arg dir "$(parseSteamShortcutEntryStartDir "${SCVDFE}")" \
--arg icon "$(parseSteamShortcutEntryIcon "${SCVDFE}")" \ --arg icon "$(parseSteamShortcutEntryIcon "${SCVDFE}")" \
--arg args "$(parseSteamShortcutEntryLaunchOptions "${SCVDFE}")" \ --arg args "$(parseSteamShortcutEntryLaunchOptions "${SCVDFE}")" \
'{id: $id, name: $name, exe: $exe, dir: $dir, icon: $icon, args: $args}' '{id: $id, name: $name, exe: $exe, dir: $dir, icon: $icon, args: $args}'
done | jq -s '.' done | jq -s '.'
} }
listSteamGames() { listSteamGames() {
( (
jq -r 'map({AppId: .id, SteamAppId: .id, SteamGameId: .id, Name: .name}) | .[] | tostring' <<< "$(listInstalledSteamGames)" jq -r 'map({AppId: .id, SteamAppId: .id, SteamGameId: .id, Name: .name}) | .[] | tostring' <<< "$(listInstalledSteamGames)"
jq -r '.[] | tostring' <<< "$(listNonSteamGames)" | while read -r game; do jq -r '.[] | tostring' <<< "$(listNonSteamGames)" | while read -r game; do
id=$(jq -r '.id' <<< "${game}") id=$(jq -r '.id' <<< "${game}")
name=$(jq -r '.name' <<< "${game}") name=$(jq -r '.name' <<< "${game}")
jq -r \ exe=$(jq -r '.exe' <<< "${game}")
--arg SteamAppId "$(getSteamId "${name}")" \ if [[ "${name}" =~ ^[0-9]+$ ]] && [[ "${exe}" =~ .sh$ ]]; then
--arg SteamGameId "$(getSteamGameId $id)" \ appid="${name}"
'{AppId: .id, SteamAppId: ($SteamAppId | if . == "" then "0" else . end), SteamGameId: $SteamGameId, Name: .name} | tostring' <<< "${game}" name=$(basename "${exe}" .sh)
else
appid="$(getSteamId "${name}")"
[[ -z "${appid}" ]] && appid="0"
fi
gid="$(getSteamGameId $id)"
jq -n \
--arg id "${id}" \
--arg appid "${appid}" \
--arg gid "${gid}" \
--arg name "${name}" \
'{AppId: $id, SteamAppId: $appid, SteamGameId: $gid, Name: $name}'
done done
) | jq -s '.' ) | jq -s '.'
} }
convertSteamShortcutAppID() { convertSteamShortcutAppID() {
SHORTCUTAPPIDHEX="$1" SHORTCUTAPPIDHEX="$1"
SHORTCUTAPPIDLITTLEENDIAN="$( echo "${SHORTCUTAPPIDHEX}" | tac -rs .. | tr -d '\n' )" SHORTCUTAPPIDLITTLEENDIAN="$( echo "${SHORTCUTAPPIDHEX}" | tac -rs .. | tr -d '\n' )"
echo "$((16#${SHORTCUTAPPIDLITTLEENDIAN}))" echo "$((16#${SHORTCUTAPPIDLITTLEENDIAN}))"
} }
convertSteamShortcutHex() { convertSteamShortcutHex() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment