forked from CastroFidel/PortWINE
getUserId getUserIds getUserPath
This commit is contained in:
parent
b0864223f0
commit
f5dd208f2a
@ -41,7 +41,8 @@ generateShortcutVDFHexAppId() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Takes an signed 32bit integer and converts it to an unsigned 32bit integer
|
# Takes an signed 32bit integer and converts it to an unsigned 32bit integer
|
||||||
generateShortcutGridAppId() {
|
extractSteamId32() {
|
||||||
|
# STUID32=$((STUID64 - 76561197960265728))
|
||||||
echo $(($1 & 0xFFFFFFFF))
|
echo $(($1 & 0xFFFFFFFF))
|
||||||
}
|
}
|
||||||
## ----------
|
## ----------
|
||||||
@ -134,29 +135,55 @@ getSteamGridDBId() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
getUserPath() {
|
getUserIds() {
|
||||||
|
SLUF="${HOME}/.local/share/Steam/config/loginusers.vdf"
|
||||||
|
if [[ -f "${SLUF}" ]]; then
|
||||||
|
STUIDS=()
|
||||||
|
while read -r line; do
|
||||||
|
if [[ "${line}" =~ ^[[:space:]]*\"([0-9]+)\"$ ]]; then
|
||||||
|
STUID=$(extractSteamId32 "${BASH_REMATCH[1]}")
|
||||||
|
STUIDS+=("${STUID}")
|
||||||
|
fi
|
||||||
|
done < "${SLUF}"
|
||||||
|
if [[ ${#STUIDS[@]} -gt 0 ]]; then
|
||||||
|
echo "${STUIDS[@]}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
getUserId() {
|
||||||
SLUF="${HOME}/.local/share/Steam/config/loginusers.vdf"
|
SLUF="${HOME}/.local/share/Steam/config/loginusers.vdf"
|
||||||
if [[ -f "${SLUF}" ]]; then
|
if [[ -f "${SLUF}" ]]; then
|
||||||
SLUFUB=false
|
SLUFUB=false
|
||||||
STUID64=""
|
STUID=""
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
if [[ "${line}" =~ ^[[:space:]]*\"([0-9]+)\"$ ]]; then
|
if [[ "${line}" =~ ^[[:space:]]*\"([0-9]+)\"$ ]]; then
|
||||||
STUIDCUR="${BASH_REMATCH[1]}"
|
STUIDCUR="${BASH_REMATCH[1]}"
|
||||||
SLUFUB=true
|
SLUFUB=true
|
||||||
elif [[ "${line}" == *'"MostRecent"'*'"1"' && ${SLUFUB} = true ]]; then
|
elif [[ "${line}" == *'"MostRecent"'*'"1"' && ${SLUFUB} = true ]]; then
|
||||||
STUID64="${STUIDCUR}"
|
STUID=$(extractSteamId32 "${STUIDCUR}")
|
||||||
break
|
break
|
||||||
elif [[ "${line}" == "}" ]]; then
|
elif [[ "${line}" == "}" ]]; then
|
||||||
SLUFUB=false
|
SLUFUB=false
|
||||||
fi
|
fi
|
||||||
done < "${SLUF}"
|
done < "${SLUF}"
|
||||||
if [ -n "${STUID64}" ]; then
|
fi
|
||||||
STUID32=$((STUID64 - 76561197960265728))
|
if [ -n "${STUID}" ]; then
|
||||||
STUIDPATH="${HOME}/.local/share/Steam/userdata/${STUID32}"
|
echo "${STUID}"
|
||||||
if [[ -d "${STUIDPATH}" ]]; then
|
fi
|
||||||
if [[ -f "${STUIDPATH}/config/shortcuts.vdf" ]]; then
|
}
|
||||||
echo "${STUIDPATH}/config"
|
|
||||||
fi
|
getUserPath() {
|
||||||
|
if [[ -n "${1:-}" ]]; then
|
||||||
|
STUID="$1"
|
||||||
|
else
|
||||||
|
STUID="$(getUserId)"
|
||||||
|
fi
|
||||||
|
if [ -n "${STUID}" ]; then
|
||||||
|
STUIDPATH="${HOME}/.local/share/Steam/userdata/${STUID}"
|
||||||
|
if [[ -d "${STUIDPATH}" ]]; then
|
||||||
|
if [[ -f "${STUIDPATH}/config/shortcuts.vdf" ]]; then
|
||||||
|
echo "${STUIDPATH}/config"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -304,17 +331,15 @@ addGrids() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
removeNonSteamGame() {
|
removeNonSteamGame() {
|
||||||
|
[[ -n "${1:-}" ]] && appid="$1"
|
||||||
if [[ -z "${STCFGPATH}" ]]; then
|
if [[ -z "${STCFGPATH}" ]]; then
|
||||||
STCFGPATH="$(getUserPath)"
|
STCFGPATH="$(getUserPath)"
|
||||||
fi
|
fi
|
||||||
if [[ -n "${STCFGPATH}" ]] && [[ -z "${SCPATH}" ]]; then
|
if [[ -n "${STCFGPATH}" ]] && [[ -z "${SCPATH}" ]]; then
|
||||||
SCPATH="${STCFGPATH}/shortcuts.vdf"
|
SCPATH="${STCFGPATH}/shortcuts.vdf"
|
||||||
fi
|
fi
|
||||||
if [[ -n "${SCPATH}" ]] && [[ -f "${SCPATH}" ]]; then
|
if [[ -n "${appid}" ]] && [[ -n "${SCPATH}" ]] && [[ -f "${SCPATH}" ]]; then
|
||||||
cp "${SCPATH}" "${SCPATH//.vdf}_${PROGNAME}_backup.vdf" 2>/dev/null
|
cp "${SCPATH}" "${SCPATH//.vdf}_${PROGNAME}_backup.vdf" 2>/dev/null
|
||||||
fi
|
|
||||||
[[ -n "${1:-}" ]] && appid="$1"
|
|
||||||
if [[ -n "${appid}" ]]; then
|
|
||||||
NOSTAIDVDFHEX=$(bigToLittleEndian $(printf '%08x' "${appid}"))
|
NOSTAIDVDFHEX=$(bigToLittleEndian $(printf '%08x' "${appid}"))
|
||||||
LC_ALL=C perl -pe '
|
LC_ALL=C perl -pe '
|
||||||
$hex = pack("H*", shift);
|
$hex = pack("H*", shift);
|
||||||
@ -354,7 +379,7 @@ addNonSteamGame() {
|
|||||||
NOSTAIDVDF="$(generateShortcutVDFAppId "${NOSTAPPNAME}${NOSTEXEPATH}")" # signed integer AppID, stored in the VDF as hexidecimal - ex: -598031679
|
NOSTAIDVDF="$(generateShortcutVDFAppId "${NOSTAPPNAME}${NOSTEXEPATH}")" # signed integer AppID, stored in the VDF as hexidecimal - ex: -598031679
|
||||||
NOSTAIDVDFHEX="$(generateShortcutVDFHexAppId "$NOSTAIDVDF")" # 4byte little-endian hexidecimal of above 32bit signed integer, which we write out to the binary VDF - ex: c1c25adc
|
NOSTAIDVDFHEX="$(generateShortcutVDFHexAppId "$NOSTAIDVDF")" # 4byte little-endian hexidecimal of above 32bit signed integer, which we write out to the binary VDF - ex: c1c25adc
|
||||||
NOSTAIDVDFHEXFMT="\x$(awk '{$1=$1}1' FPAT='.{2}' OFS="\\\x" <<< "$NOSTAIDVDFHEX")" # binary-formatted string hex of the above which we actually write out - ex: \xc1\xc2\x5a\xdc
|
NOSTAIDVDFHEXFMT="\x$(awk '{$1=$1}1' FPAT='.{2}' OFS="\\\x" <<< "$NOSTAIDVDFHEX")" # binary-formatted string hex of the above which we actually write out - ex: \xc1\xc2\x5a\xdc
|
||||||
NOSTAIDGRID="$(generateShortcutGridAppId "$NOSTAIDVDF")" # unsigned 32bit ingeger version of "$NOSTAIDVDF", which is used as the AppID for Steam artwork ("grids"), as well as for our shortcuts
|
NOSTAIDGRID="$(extractSteamId32 "$NOSTAIDVDF")" # unsigned 32bit ingeger version of "$NOSTAIDVDF", which is used as the AppID for Steam artwork ("grids"), as well as for our shortcuts
|
||||||
|
|
||||||
create_new_dir "${STEAM_SCRIPTS}"
|
create_new_dir "${STEAM_SCRIPTS}"
|
||||||
echo "#!/usr/bin/env bash" > "${NOSTSHPATH}"
|
echo "#!/usr/bin/env bash" > "${NOSTSHPATH}"
|
||||||
|
Loading…
Reference in New Issue
Block a user