#!/usr/bin/bash

# Setting this variable will enable additional
# options under settings in SteamOS mode, including the option 
# to 'Automatically Set Resolution' option, which can be turned
# off to set the resolution manually.
export GAMESCOPE_MODE_SAVE_FILE="$HOME/.config/gamescope/modes.cfg"

# Assume that MangoHud is not installed
MANGOAPP_FLAG=""

# Check that mangoapp is available. Set the flag if it exists,
# otherwise inform to check that MangoHud is installed and
# proceed without the flag.
if command -v mangoapp &> /dev/null;
then
    MANGOAPP_FLAG="--mangoapp"
else
    printf "[%s] [Info] 'mangoapp' is not available on your system. Check to see that MangoHud is installed.\n" "$0"
    printf "[%s] [Info] Continuing without the '--mangoapp' flag.\n" "$0"
fi

gamescope \
    --prefer-output $GAMESCOPE_SESSION_OUTPUT \
    $MANGOAPP_FLAG \
    -e -- steam -steamdeck -steamos3