Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bash script to switch aspect ratios between 4:3 and 16:9 for Retroarch cores
#!/bin/bash
# 1.0
# (c) Apr 2018 Kelly Lawrence
#########
# NOTES #
#########
# aspect_ratio_index = "21" // Core Provided
# aspect_ratio_index = "22" // Custom
# aspect_ratio_index = "0" // 4:3 (Or lack of aspect_ratio_index apparently)
# aspect_ratio_index = "1" // 16:9
##########
# Colors #
##########
RED='\033[0;31m'
NC='\033[0m'
#############
# Variables #
#############
if [ $# -eq 0 ] # If no argument passed
then
DisplayType="null"
else
DisplayType=$1
fi
# Retroarch configuration path
ConfigPath=~/.config/retroarch/config
# Console core configuration paths
GBA=mGBA/mGBA.cfg
NES=FCEUmm/FCEUmm.cfg
PSX=PCSX-ReARMed/PCSX-ReARMed.cfg
SEGA=PicoDrive/PicoDrive.cfg
SNES=Snes9x\ 2010/Snes9x\ 2010.cfg
TG16=Mednafen\ PCE\ Fast/Mednafen\ PCE\ Fast.cfg
######################
# Display Type Check #
######################
# TO DO #
#echo "Display is"
#tvservice -s -n
# If using HDMI monitor
if [ $DisplayType == "HDMI" ]
then
echo -e "${RED}Switching Castlevania: Symphony of the Night aspect ratio from \"Custom\" to \"4:3\"${NC}"
sed -i 's/aspect_ratio_index = "22"/aspect_ratio_index = "0"/g' ~/.config/retroarch/config/PCSX-ReARMed/Castlevania\ -\ Symphony\ of\ the\ Night.cfg
echo -e "${RED}Switching core console aspect ratios from \"16:9\" to \"4:3\"${NC}"
sed -i 's/aspect_ratio_index = "1"/aspect_ratio_index = "0"/g' $ConfigPath/"$GBA" $ConfigPath/"$NES" $ConfigPath/"$PSX" $ConfigPath/"$SEGA" $ConfigPath/"$SNES" $ConfigPath/"$TG16"
echo -e "${RED}Switching audio output to HDMI${NC}"
amixer -q cset numid=3 2 && amixer -q set PCM 100%
# If using HDMI to RCA converter
elif [ $DisplayType == "RCA" ]
then
echo -e "${RED}Switching Castlevania: Symphony of the Night aspect ratio from \"4:3\" to \"Custom\"${NC}"
sed -i 's/aspect_ratio_index = "0"/aspect_ratio_index = "22"/g' ~/.config/retroarch/config/PCSX-ReARMed/Castlevania\ -\ Symphony\ of\ the\ Night.cfg
echo -e "${RED}Switching core console aspect ratios from \"4:3\" to \"16:9\"${NC}"
sed -i 's/aspect_ratio_index = "0"/aspect_ratio_index = "1"/g' $ConfigPath/"$GBA" $ConfigPath/"$NES" $ConfigPath/"$PSX" $ConfigPath/"$SEGA" $ConfigPath/"$SNES" $ConfigPath/"$TG16"
echo -e "${RED}Switching audio output to 3.5mm${NC}"
amixer -q cset numid=3 1 && amixer -q set PCM 80%
# IF NOTHING!!!
else
echo -e "Options are ${RED}HDMI${NC} or ${RED}RCA${NC}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment