Commit df86ec04 authored by Alex Smith's avatar Alex Smith

getAppExe

parent f5dd208f
...@@ -74,10 +74,14 @@ getSteamShortcutEntryHex() { ...@@ -74,10 +74,14 @@ getSteamShortcutEntryHex() {
printf "%s" "${SHORTCUTSVDFINPUTHEX}" | grep -oP "${SHORTCUTSVDFMATCHPATTERN}\K.*?(?=${SHORTCUTVDFENDPAT})" printf "%s" "${SHORTCUTSVDFINPUTHEX}" | grep -oP "${SHORTCUTSVDFMATCHPATTERN}\K.*?(?=${SHORTCUTVDFENDPAT})"
} }
getAppExe() {
[[ -n "$1" ]] && listNonSteamGames | jq -r --arg id "$1" 'map(select(.id == $id)) | first(.[].exe)'
}
getAppTarget() { getAppTarget() {
exe=$(listNonSteamGames | jq -r --arg id "$1" 'map(select(.id == $id)) | first(.[].exe)') exe=$(getAppExe "$1")
if [[ -n "${exe}" ]]; then if [[ -n "${exe}" ]]; then
if [[ "${exe}" =~ .sh$ ]] ; then if [[ "${exe}" =~ .sh$ ]]; then
parseSteamTargetExe "${exe}" parseSteamTargetExe "${exe}"
else else
echo "${exe}"; echo "${exe}";
...@@ -90,7 +94,7 @@ getSteamGameId() { ...@@ -90,7 +94,7 @@ getSteamGameId() {
} }
getAppId() { getAppId() {
listNonSteamGames | jq -r --arg exe "$1" 'map(select(.exe == $exe)) | first(.[]?.id)' [[ -n "$1" ]] && listNonSteamGames | jq -r --arg exe "$1" 'map(select(.exe == $exe)) | first(.[]?.id)'
} }
getSteamId() { getSteamId() {
...@@ -141,8 +145,7 @@ getUserIds() { ...@@ -141,8 +145,7 @@ getUserIds() {
STUIDS=() STUIDS=()
while read -r line; do while read -r line; do
if [[ "${line}" =~ ^[[:space:]]*\"([0-9]+)\"$ ]]; then if [[ "${line}" =~ ^[[:space:]]*\"([0-9]+)\"$ ]]; then
STUID=$(extractSteamId32 "${BASH_REMATCH[1]}") STUIDS+=("$(extractSteamId32 "${BASH_REMATCH[1]}")")
STUIDS+=("${STUID}")
fi fi
done < "${SLUF}" done < "${SLUF}"
if [[ ${#STUIDS[@]} -gt 0 ]]; then if [[ ${#STUIDS[@]} -gt 0 ]]; then
...@@ -332,13 +335,14 @@ addGrids() { ...@@ -332,13 +335,14 @@ addGrids() {
removeNonSteamGame() { removeNonSteamGame() {
[[ -n "${1:-}" ]] && appid="$1" [[ -n "${1:-}" ]] && appid="$1"
if [[ -z "${STCFGPATH}" ]]; then [[ -n "${2:-}" ]] && NOSTSHPATH="$2"
STCFGPATH="$(getUserPath)" [[ -z "${STUID}" ]] && STUID=$(getUserId)
fi [[ -z "${STCFGPATH}" ]] && STCFGPATH="$(getUserPath ${STUID})"
if [[ -n "${STCFGPATH}" ]] && [[ -z "${SCPATH}" ]]; then if [[ -n "${STCFGPATH}" ]] && [[ -z "${SCPATH}" ]]; then
SCPATH="${STCFGPATH}/shortcuts.vdf" SCPATH="${STCFGPATH}/shortcuts.vdf"
fi fi
if [[ -n "${appid}" ]] && [[ -n "${SCPATH}" ]] && [[ -f "${SCPATH}" ]]; then if [[ -n "${appid}" ]] && [[ -n "${SCPATH}" ]] && [[ -f "${SCPATH}" ]]; then
[[ -z "${NOSTSHPATH}" ]] && NOSTSHPATH=$(getAppExe ${appid})
cp "${SCPATH}" "${SCPATH//.vdf}_${PROGNAME}_backup.vdf" 2>/dev/null cp "${SCPATH}" "${SCPATH//.vdf}_${PROGNAME}_backup.vdf" 2>/dev/null
NOSTAIDVDFHEX=$(bigToLittleEndian $(printf '%08x' "${appid}")) NOSTAIDVDFHEX=$(bigToLittleEndian $(printf '%08x' "${appid}"))
LC_ALL=C perl -pe ' LC_ALL=C perl -pe '
...@@ -357,6 +361,21 @@ removeNonSteamGame() { ...@@ -357,6 +361,21 @@ removeNonSteamGame() {
mv "${SCPATH}~" "${SCPATH}" mv "${SCPATH}~" "${SCPATH}"
rm -f "${STCFGPATH}/grid/${appid}.jpg" "${STCFGPATH}/grid/${appid}p.jpg" "${STCFGPATH}/grid/${appid}_hero.jpg" "${STCFGPATH}/grid/${appid}_logo.png" rm -f "${STCFGPATH}/grid/${appid}.jpg" "${STCFGPATH}/grid/${appid}p.jpg" "${STCFGPATH}/grid/${appid}_hero.jpg" "${STCFGPATH}/grid/${appid}_logo.png"
fi fi
if [[ -n "${STUID}" ]] && [[ -n "${NOSTSHPATH}" ]] && [[ -f "${NOSTSHPATH}" ]]; then
isInstallGame=false
for STUIDCUR in $(getUserIds); do
[[ "${STUIDCUR}" == "${STUID}" ]] && continue
STCFGPATH="$(getUserPath ${STUIDCUR})"
SCPATH="${STCFGPATH}/shortcuts.vdf"
if [[ -n "$(getAppId "${NOSTSHPATH}")" ]]; then
isInstallGame=true
break
fi
done
if [[ ${isInstallGame} == false ]]; then
rm "${NOSTSHPATH}"
fi
fi
} }
addNonSteamGame() { addNonSteamGame() {
......
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