Updated scripts, bufgix needed

This commit is contained in:
Steam Deck User 2022-07-23 20:19:03 +02:00
parent c803fbdee2
commit 353ad896c5
2 changed files with 67 additions and 37 deletions

View file

@ -2,20 +2,36 @@
# This file is containing some global function needed for the script such as the config file tools
rd_conf="/app/retrodeck/retrodeck.cfg"
rd_conf="/var/config/retrodeck/retrodeck.cfg"
conf_init() {
# initializing and reading the retrodeck config file
if [ ! -f $rd_conf ]
then # I have to initialize the variables as they cannot be red from an empty config file
echo "RetroDECK config file not found in $rd_conf"
echo "Initializing"
touch $rd_conf
read -p "Press enter to continue" #DEBUG
# Variables to manage: adding a variable here means adding it to conf_write()
version="$(cat /app/retrodeck/version)" # version info taken from the version file
rdhome="$HOME/retrodeck" # the retrodeck home, aka ~/retrodeck
roms_folder="$rdhome/roms" # default roms folder location (intenral)
echo "#!/bin/bash" >> $rd_conf
# version info taken from the version file
version="$(cat /app/retrodeck/version)"
echo "version=$version" >> $rd_conf
# the retrodeck home, aka ~/retrodeck
rdhome="$HOME/retrodeck"
echo "rdhome=$rdhome" >> $rd_conf
# default roms folder location (internal)
roms_folder="$rdhome/roms"
echo "roms_folder=$roms_folder" >> $rd_conf
else # i just read the variables
echo "Found RetroDECK config file in $rd_conf"
echo "Loading it"
source $rd_conf
fi
}
@ -23,17 +39,22 @@ conf_init() {
conf_write() {
# writes the variables in the retrodeck config file
echo "Writing the config file"
# TODO: this can be optimized with a while and a list of variables to check
if [ ! -z "$version" ] then #if the variable is not null then I update it
if [ ! -z "$version" ] #if the variable is not null then I update it
then
sed -i "s%version=.*%version=$version%" $rd_conf
fi
if [ ! -z "$rdhome" ] then
if [ ! -z "$rdhome" ]
then
sed -i "s%rdhome=.*%rdhome=$rdhome%" $rd_conf
fi
if [ ! -z "$roms_folder" ] then
sed -i "s%rdhome=.*%rdhome=$roms_folder" $rd_conf
if [ ! -z "$roms_folder" ]
then
sed -i "s%rdhome=.*%rdhome=$roms_folder%" $rd_conf
fi
}

View file

@ -5,11 +5,11 @@
lockfile="/var/config/retrodeck/.lock" # where the lockfile is located
emuconfigs="/app/retrodeck/emu-configs" # folder with all the default emulator configs
sdcard="/run/media/mmcblk0p1" # Steam Deck SD default path
rd_conf="/app/retrodeck/retrodeck.cfg" # RetroDECK config file path
rd_conf="/var/config/retrodeck/retrodeck.cfg" # RetroDECK config file path
version="$(cat /app/retrodeck/version)" # version info taken from the version file
rdhome="$HOME/retrodeck" # the retrodeck home, aka ~/retrodeck
source global.sh
source /app/bin/global.sh
# We moved the lockfile in /var/config/retrodeck in order to solve issue #53 - Remove in a few versions
if [ -f "$HOME/retrodeck/.lock" ]
@ -191,11 +191,14 @@ ra_init() {
mv -fv $rdhome/bios/PPSSPP/flash0/font $rdhome/bios/PPSSPP/flash0/font.bak
fi
mkdir -p $rdhome/bios/PPSSPP
wget "https://github.com/hrydgard/ppsspp/archive/refs/heads/master.zip" -P $rdhome/bios/PPSSPP
unzip "$rdhome/bios/PPSSPP/master.zip" -d $rdhome/bios/PPSSPP/
mv "$rdhome/bios/PPSSPP/ppsspp-master/"* "$rdhome/bios/PPSSPP/"
rm -rfv "$rdhome/bios/PPSSPP/master.zip"
rm -rfv "$rdhome/bios/PPSSPP/ppsspp-master"
if [ ! -f "$rdhome/bios/PPSSPP/ppge_atlas.zim" ]
then
wget "https://github.com/hrydgard/ppsspp/archive/refs/heads/master.zip" -P $rdhome/bios/PPSSPP
unzip "$rdhome/bios/PPSSPP/master.zip" -d $rdhome/bios/PPSSPP/
mv "$rdhome/bios/PPSSPP/ppsspp-master/assets"* "$rdhome/bios/PPSSPP/"
rm -rfv "$rdhome/bios/PPSSPP/master.zip"
rm -rfv "$rdhome/bios/PPSSPP/ppsspp-master"
fi
if [ -d $rdhome/bios/PPSSPP/flash0/font.bak ]
then
mv -fv $rdhome/bios/PPSSPP/flash0/font.bak $rdhome/bios/PPSSPP/flash0/font
@ -256,6 +259,32 @@ start_retrodeck() {
emulationstation --home /var/config/emulationstation
}
browse(){
# Function fro browsing the sd card or [ath]
path_selected=false
while [ $path_selected == false ]
do
sdcard="$(zenity --file-selection --title="Choose retrodeck folder location" --directory)"
echo "Path choosed: $sdcard, answer=$?"
zenity --question --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" \
--cancel-label="No" \
--ok-label "Yes" \
--text="Your rom folder will be:\n\n$sdcard/retrodeck/roms\n\nis that ok?"
if [ $? == 0 ] #yes
then
sdselected == true
roms_folder="$sdcard/retrodeck/roms"
break
else
zenity --question --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" --cancel-label="No" --ok-label "Yes" --text="Do you want to quit?"
if [ $? == 0 ] # yes, quit
then
exit 0
fi
fi
done
}
finit() {
# Force/First init, depending on the situation
@ -293,6 +322,7 @@ finit() {
--title "RetroDECK" --cancel-label="Cancel" \
--ok-label "Browse" \
--text="SD Card was not find in the default location.\nPlease choose the SD Card root.\nA retrodeck/roms folder will be created starting from the directory that you selected."
browse
else
roms_folder="$sdcard/retrodeck/roms"
echo "ROMs folder = $roms_folder"
@ -302,28 +332,7 @@ finit() {
"Browse" ) # Browse + not found fallback
echo "Browse"
path_selected=false
while [ $path_selected == false ]
do
sdcard="$(zenity --file-selection --title="Choose retrodeck folder location" --directory)"
echo "Path choosed: $sdcard, answer=$?"
zenity --question --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" \
--cancel-label="No" \
--ok-label "Yes" \
--text="Your rom folder will be:\n\n$sdcard/retrodeck/roms\n\nis that ok?"
if [ $? == 0 ] #yes
then
sdselected == true
roms_folder="$sdcard/retrodeck/roms"
break
else
zenity --question --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --title "RetroDECK" --cancel-label="No" --ok-label "Yes" --text="Do you want to quit?"
if [ $? == 0 ] # yes, quit
then
exit 0
fi
fi
done
browse
;;
esac