Skip to content

Instantly share code, notes, and snippets.

@dpanter
Created April 13, 2025 17:51
Show Gist options
  • Save dpanter/6c2849324e6e412bb128f3e27e745217 to your computer and use it in GitHub Desktop.
Save dpanter/6c2849324e6e412bb128f3e27e745217 to your computer and use it in GitHub Desktop.
ntg.sh - NameThatGame (by MoistGoat)
#!/bin/bash
# creds to MoistGoat from GamingOnLinux.com Discord
# Run this script in your compatdata folder!
CreateLinksAllowed=0
OutputListToFile=1
Dependencies() {
if [[ ! $(command -v jq) ]]; then
echo "The package " jq " is missing, it will not work without."
else
NameThatGame
CreateLinks
fi
}
NameThatGame() {
FolderList=($(ls -d *))
## Lines 19 to 24 ensures it's looking only for integers
for i in "${FolderList[@]}"; do
check=`echo "$i" | grep -E ^\-?[0-9]+$`
if [ "$check" != '' ]; then
AppIDs+=("$i")
fi
done
# Lines 26 to 31 is checking the ID's and getting a name
for ID in ${AppIDs[*]}; do
Name=$(curl -s https://store.steampowered.com/api/appdetails?appids=$ID | jq . | head -n 7 | awk '/name/ {print $0}' | cut -f8- -d' ') &> /dev/null
Game=$(echo -e "$ID : $Name\n" | tr -d '"' | tr -d ',')
Output[${#Output[@]}]="$Game"
done
# Lists output of above
printf "%s\n" "${Output[@]}" | sort -n
if [[ $OutputListToFile == "1" ]]; then
printf "%s\n" "${Output[@]}" | sort -n > "$PWD/ids-to-name.txt"
fi
}
CreateLinks() { # Creates links to the games ID name inside a folder called symlinks
if [[ $CreateLinksAllowed == "1" ]]; then
for i in "${Output[@]}"; do
FolderID=$(echo $i | cut -f1 -d' ')
GameName=$(echo $i | cut -f3- -d' ')
mkdir -p "$PWD/symlinks"
if [[ ! -d "$PWD/symlinks/$GameName" ]]; then #Makes sure that the link doesnt exist to avoid a bug
ln -s "$PWD/$FolderID" "$PWD/symlinks/$GameName"
fi
done
fi
}
Dependencies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment