Skip to content

Instantly share code, notes, and snippets.

@jleem99
Last active September 27, 2024 11:32
Show Gist options
  • Save jleem99/187155143851161e69be8a0c54a83a8c to your computer and use it in GitHub Desktop.
Save jleem99/187155143851161e69be8a0c54a83a8c to your computer and use it in GitHub Desktop.
Bash script that enables Metal API for League of Legends on macOS

Bash script that enables Metal API for League of Legends on macOS.

After installing League of Legends, you can run this script to enable Metal API for the game.
You can expect a performance boost of up to ~2x FPS.

How to run

To run the script, download the script and run it in Terminal.
Or, open Terminal and type the following command:

curl -fsSL https://gist.githubusercontent.com/jleem99/187155143851161e69be8a0c54a83a8c/raw/cf365118503feef7b2aa56e42a4a50e9b7da7a1b/league-of-legends-enable-metal-api.sh | bash
#! /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!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment