|
#! /bin/bash |
|
# File : league-of-legends-enable-metal-api.sh |
|
# Author : JongHan Leem <[email protected]> |
|
# Description : This script enables Metal API for League of Legends on macOS. |
|
|
|
set -e |
|
|
|
ENABLE_METAL_API_KEY="MetalBetaTest" |
|
|
|
# # Check if the script is run as root |
|
# if [[ $EUID -ne 0 ]]; then |
|
# echo "This script must be run as root." |
|
# exit 1 |
|
# fi |
|
|
|
# Check if the script is run on macOS |
|
if [[ $(uname) != "Darwin" ]]; then |
|
echo "This script must be run on macOS." |
|
exit 1 |
|
fi |
|
|
|
# Detect League of Legends installation path |
|
if [[ -d "/Applications/League of Legends.app" ]]; then |
|
LOL_PATH="/Applications/League of Legends.app" |
|
elif [[ -d "$HOME/Applications/League of Legends.app" ]]; then |
|
LOL_PATH="$HOME/Applications/League of Legends.app" |
|
else |
|
echo "Could not detect League of Legends installation path." |
|
echo "Please install League of Legends in /Applications or $HOME/Applications." |
|
exit 1 |
|
fi |
|
|
|
# Check if League of Legends is running |
|
if [[ $(pgrep "League of Legends") ]]; then |
|
echo "League of Legends is running. Please quit the game and try again." |
|
exit 1 |
|
fi |
|
|
|
GAME_CFG_PATH="$LOL_PATH/Contents/LoL/Config/game.cfg" |
|
|
|
# Check if game.cfg exists |
|
if [[ ! -f "$GAME_CFG_PATH" ]]; then |
|
echo "game.cfg does not exist, creating one..." |
|
printf "[General]\r\n" > "$GAME_CFG_PATH" |
|
fi |
|
|
|
# Check if EnableMetalAPI is already set to 1 |
|
if [[ $(grep -c "$ENABLE_METAL_API_KEY=1" "$GAME_CFG_PATH") -ne 0 ]]; then |
|
echo "Metal API is already enabled." |
|
exit 1 |
|
fi |
|
|
|
# Add Metal API support to League of Legends |
|
echo "Adding Metal API support to League of Legends..." |
|
|
|
# Remove existing line containing EnableMetalAPI |
|
sed -i '' "/$ENABLE_METAL_API_KEY/d" "$GAME_CFG_PATH" |
|
|
|
# Add $ENABLE_METAL_API_KEY=1 under [General] section |
|
sed -i '' "/\[General\]/a\\ |
|
$ENABLE_METAL_API_KEY=1"$'\r\n' "$GAME_CFG_PATH" |
|
|
|
# Done! |
|
echo "Done." |
|
echo "Enjoy League of Legends with Metal API!" |