Skip to content

Instantly share code, notes, and snippets.

@FlaareZero
Forked from xlash123/kh-1-5.sh
Last active October 8, 2021 20:04
Show Gist options
  • Save FlaareZero/602123849438e6f8ce5831fc3030cae6 to your computer and use it in GitHub Desktop.
Save FlaareZero/602123849438e6f8ce5831fc3030cae6 to your computer and use it in GitHub Desktop.
Launch Kingdom Hearts 1.5+2.5 on Linux using Legendary and Heroic Games Launcher
#!/bin/sh
# This script requires that you set certain variables before running it.
# After that, you can just run the command and the game will launch!
# Instructions can be found at https://github.com/FlaareZero/Kingdom_Hearts_Collection_Linux/issues/2#issuecomment-890655837
# STEP 1: Environment variables from Heroic
HEROIC_ENV="" # Paste in the quotes
# STEP 2: Wine command from Heroic
HEROIC_WINE="" # Paste in the quotes
# STEP 3: Directory of KH1.5
# By default, this is ~/legendary/KH_1.5_2.5
# If you have it there too, you may skip this step
KH_DIR="$HOME/legendary/KH_1.5_2.5"
# In case you wanna go for KH 2.8, you may want to include your directory here:
KH_2.8="$HOME/legendary/pathtoKH2.8"
# STEP 4: You're all done! Run the command now
# The Id of the game as seen in the output of `legendary list-games`
KH_GAMEID="68c214c58f694ae88c2dab6f209b43e4"
# Ask what game to play
echo "Launch which game?"
echo "1) Kingdom Hearts 1"
echo "2) Kingdom Hearts 2"
echo "3) Kingdom Hearts Re: Chain of Memories"
echo "4) Kingdom Hearts Birth by Sleep"
echo "5) Kingdom Hearts Dream Drop Distance"
echo "6) Kingdom Hearts 2.8 - A Fragmentary Passage"
read KH_CHOICE
# Get the path for the KH binary to play
KH_BIN=""
case $KH_CHOICE in
1)
KH_BIN="'$KH_DIR/KINGDOM HEARTS FINAL MIX.exe'";;
2)
KH_BIN="'$KH_DIR/KINGDOM HEARTS II FINAL MIX.exe'";;
3)
KH_BIN="'$KH_DIR/KINGDOM HEARTS Re_Chain of Memories.exe'";;
4)
KH_BIN="'$KH_DIR/KINGDOM HEARTS Birth by Sleep FINAL MIX.exe'";;
5)
KH_BIN="'$KH_2.8/KINGDOM HEARTS Dream Drop Distance.exe'";; # you should change that and the bottom one as the output of legendary list-games for KH2.8
KH_GAMEID="68c214c58f694ae88c2dab6f209b43e4"
6)
KH_BIN="'$KH_2.8/KINGDOM HEARTS A Fragmentary Passage.exe'";; #if specified differently, please feel free to change it
KH_GAMEID="68c214c58f694ae88c2dab6f209b43e4"
*)
echo "Invalid game selection" && exit;;
esac
# Get the session from Legendary
RAW_LEGEND=$(legendary launch --dry-run $KH_GAMEID 2>&1 >/dev/null)
TMP=${RAW_LEGEND#*.exe\'\ }
# This holds the session tokens in argument form
ARG_AUTH=${TMP%\[cli\]\ INFO:\ Working*}
# The command all combined
FINAL_COMMAND="$HEROIC_ENV $HEROIC_WINE $KH_BIN $ARG_AUTH"
# Echo for debugging purposes
echo $FINAL_COMMAND
# Run it
sh -c "$FINAL_COMMAND"
@xlash123
Copy link

xlash123 commented Oct 8, 2021

You set the same game ID in 5 and 6 as the ID for KH1.5+2.5. Is this correct, or does KH2.8 have a different game id? I don't own the game, so I can't check.

@FlaareZero
Copy link
Author

You set the same game ID in 5 and 6 as the ID for KH1.5+2.5. Is this correct, or does KH2.8 have a different game id? I don't own the game, so I can't check.

Yeah, it is. They actually have 2 different ID, and as such the reason for 2 variables :3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment