Skip to content

Instantly share code, notes, and snippets.

@binaryaaron
Last active August 7, 2023 20:19
Show Gist options
  • Save binaryaaron/910890d90cf1053ec47e7edec853b0f4 to your computer and use it in GitHub Desktop.
Save binaryaaron/910890d90cf1053ec47e7edec853b0f4 to your computer and use it in GitHub Desktop.
Script to open magic the gathering arena on MacOS with correct resolution.
#!/bin/bash
help()
{
# Display Help
echo "Launches MTGA with Epic's command line options and fills in screen
resolution"
echo
echo "Syntax: mtga_open.sh [h|r]"
echo "options:"
echo "h Print this Help."
echo "r Launch using the real system resolution, not the apparent UI resolution"
echo
}
while getopts ":hr" option; do
case $option in
h) # display Help
help
exit;;
r) resolution="real" ;;
esac
done
# system_profiler SPDisplaysDataType
# there are two lines shown in the config generated from the above command;
# the 'real' resolution and the apparent UI resolution.
# output looks something like:
# Graphics/Displays:
#
# Apple M1:
#
# Chipset Model: Apple M1
# Type: GPU
# Bus: Built-In
# Total Number of Cores: 8
# Vendor: Apple (0x106b)
# Metal Family: Supported, Metal GPUFamily Apple 7
# Displays:
# Color LCD:
# Resolution: 3360 x 2100
# UI Looks like: 1680 x 1050 @ 60.00Hz
# Main Display: Yes
# Mirror: Off
# Online: Yes
# Automatically Adjust Brightness: No
# Connection Type: Internal
if [[ "$resolution" = "real" ]]; then
res_line=$(system_profiler SPDisplaysDataType | grep 'Resolution')
else
res_line=$(system_profiler SPDisplaysDataType | grep 'UI')
fi
# this parses the resolution from the above line
if [[ "$res_line" =~ :[[:space:]]([0-9]{4})[[:space:]]x[[:space:]]([0-9]{4}) ]]; then
width=${BASH_REMATCH[1]}
height=${BASH_REMATCH[2]}
else
echo "no match found"
width=2560
height=1440
fi
echo "using resolution: $width x $height"
MTGA_APP='/Users/Shared/Epic\ Games/MagicTheGathering/MTGA.app/Contents/MacOS/MTGA'
ARGS=('-force-metal' '-force-low-power-device' '-screen-fullscreen 1' "-screen-width $width" "-screen-height $height")
MTGA_CMD="$MTGA_APP ${ARGS[*]}"
echo "running $MTGA_CMD"
eval "$MTGA_CMD"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment