Last active
March 13, 2025 12:13
-
-
Save sheepymeh/c7d33d0f1044effe9237502c0ce569f8 to your computer and use it in GitHub Desktop.
Bash script to generate .desktop files for the Legendary launcher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
INSTALLED_GAMES="$(legendary list-installed | grep -oP '(?<=\* ).*?(?= \()')" | |
while :; do | |
read -p "Name of game: " GAME_NAME | |
if echo "$INSTALLED_GAMES" | grep -xq "$GAME_NAME"; then break; fi | |
echo "The game $GAME_NAME is not installed" | |
done | |
GAME_ID=$(legendary list-installed | grep "* $GAME_NAME (" | grep -oP '(?<=App name: ).*?(?= \|)') | |
wget -qO "$HOME/.config/legendary/metadata/$GAME_ID.thumb" "$(jq -r '.metadata.keyImages[1].url' $HOME/.config/legendary/metadata/$GAME_ID.json)" | |
cat <<EOF >"$HOME/.local/share/applications/${GAME_NAME// /}.desktop" | |
[Desktop Entry] | |
Type=Application | |
Version=1.0 | |
Name=$GAME_NAME | |
Exec=env MANGOHUD=1 legendary launch $GAME_NAME | |
Icon=$HOME/.config/legendary/metadata/$GAME_ID.thumb | |
Terminal=false | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment