Skip to content

Instantly share code, notes, and snippets.

@awmv
Last active January 20, 2024 18:16
Show Gist options
  • Save awmv/f9ac580570a9f39f7a6828a492f6d86c to your computer and use it in GitHub Desktop.
Save awmv/f9ac580570a9f39f7a6828a492f6d86c to your computer and use it in GitHub Desktop.
These scripts dynamically adjust the permissions of League of Legends game settings based on whether a game is running. This ensures consistent settings across multiple League of Legends accounts while allowing adjustments during gameplay, without the need for manual permission changes.

League of Legends Global Settings for Mac

These scripts dynamically adjust the permissions of League of Legends game settings based on whether a game is running. This ensures consistent settings across multiple League of Legends accounts while allowing adjustments during gameplay, without the need for manual permission changes. The game state monitoring begins with the starting script and automatically terminates upon closing the Riot client or stopping the script manually.

Usage examples:

chmod +x start_lol.sh
chmod +x monitor_game_state.sh
./start_lol.sh
./start_lol.sh -d
./start_lol.sh --debug

Flow

Flow

#!/bin/bash
set -e
LOL_ABSOLUTE_SETTINGS_PATH="/Applications/League of Legends.app/Contents/LoL/Config/PersistedSettings.json"
LOL_CLIENT_LOCKFILE="/Applications/League of Legends.app/Contents/LoL/lockfile"
LOL_GAME_PROCESS_NAME="LeagueofLegends"
RIOT_CLIENT_PROCESS_NAME="RiotClient"
READ_ONLY_PERMISSION=444
READ_WRITE_PERMISSION=644
INTERVAL_IN_SECONDS=10
writeable=
debugging=false
if test "$1" = "--debug" || test "$1" = "-d"; then
debugging=true
fi
log() {
if $debugging; then
echo "$1"
fi
}
set_permissions() {
local file="$1"
local permission="$2"
local current_permission=$(stat -f "%OLp" "$file")
if [ "$current_permission" != "$permission" ]; then
chmod "$permission" "$file"
log "File permissions set to $permission."
fi
}
handle_interrupt() {
echo "Received interrupt signal (Ctrl+C). Changing file permissions to 444."
set_permissions "$LOL_ABSOLUTE_SETTINGS_PATH" 444
exit 0
}
trap 'handle_interrupt' INT
while true; do
if ! pgrep -f "$RIOT_CLIENT_PROCESS_NAME" >/dev/null; then
echo "Riot Client is not running. Exiting script."
set_permissions "$LOL_ABSOLUTE_SETTINGS_PATH" $READ_ONLY_PERMISSION
exit 0
fi
if pgrep -f "$LOL_GAME_PROCESS_NAME" >/dev/null; then
log "League of Legends game is running."
if $writeable; then
log "File is already writeable."
else
log "File is not writeable. Changing file permissions."
set_permissions "$LOL_ABSOLUTE_SETTINGS_PATH" $READ_WRITE_PERMISSION
writeable=true
fi
else
log "League of Legends game is not running."
if ! $writeable; then
log "File is already read-only."
else
log "File is writeable. Changing file permissions."
set_permissions "$LOL_ABSOLUTE_SETTINGS_PATH" $READ_ONLY_PERMISSION
writeable=false
fi
fi
sleep $INTERVAL_IN_SECONDS
done
#!/bin/bash
set -e
LOL_PATH="/Applications/League of Legends.app"
MAX_DELAY_IN_SECONDS=60
RIOT_CLIENT="RiotClient"
debugging_arg=
debugging=false
delay_in_seconds=2
open "$LOL_PATH"
if test "$1" = "--debug" || test "$1" = "-d"; then
debugging_arg="--debug"
debugging=true
fi
while true; do
if pgrep -f "$RIOT_CLIENT" >/dev/null; then
echo "Riot Client is running. Starting monitor script with debugging=$debugging."
source ./monitor_game_state.sh "$debugging_arg"
break
else
echo "Waiting for Riot Client to start..."
sleep $delay_in_seconds
delay_in_seconds=$((DELAY * 2))
if ((delay_in_seconds > MAX_DELAY_IN_SECONDS)); then
delay_in_seconds=$MAX_DELAY_IN_SECONDS
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment