Script: Advanced Settings (GPI Case 2 Edition)
-
Use at your own Risk!
Here is another script I've written over the past few days.
It was only tested with a GPI Case 2 without Dock and has opinions especially for that case!
Also the method of deactivating Bluetooth and WiFi are only made for Pi 4s. I don't know if using this method would affect the older Pi versions or would be just ignored.The main purpose is to be able to change certain things without the need for a Keyboard or SSH.
Features:
- Toggle BlueTooth / WiFi (CM4/Pi4 only)
- Switch Audio output [Stereo(Headphones) / Mono(Speaker)] (GPI Case 2 only)
- Toggle Ports Audio Fix
- Toggle EmulationStation Splash
- Toggle EmulationStation Exit option
- Reset EmulationStation UI to Full
- Toggle RetroArch Controller Notification
- Install GPI Case 2 SafeShutdown script (GPI Case 2 only)
Explanations:
- Toggle BlueTooth / WiFi (CM4/Pi4 only)
Both modules are directly dis-/enabled via config.txt - Switch Audio output
The GPI Case 2 Speaker is not properly wired and will bypass default only output one channel. This option sets the output to Mono so that the Speaker is fully used. - Toggle Ports Audio Fix
I actually have no idea what the original problem was. I just noticed this post here: https://retropie.org.uk/forum/topic/29888/no-sound-in-ports/3?_=1659129304380
I just added it because it was simple. Haven't tested it myself. - Toggle EmulationStation Splash
This will de-/activate the EmulationStation Splash Screen. The one with the ES logo and progress bar, not the Retropie Splash. - Toggle EmulationStation Exit option
This will hide/show the option to Exit EmulationStation from EmulationStations Power menu. I mean why do you want to exit to a terminal on a handheld!? - Reset EmulationStation UI to Full
This will reset EmulationStations UI mode from Kid/Kiosk to Full. The normal unlocked system never worked for me, that's why this option is here. - Toggle RetroArch Controller Notification
This will hide/show the (Xbox) Controller notification when starting a game. Again, seems like a useless feature on an handheld. - Install GPI Case 2 SafeShutdown script (GPI Case 2 only)
It does what it says. Like I said, the purpose is to not rely on a Keyboard or SSH.
Important: It is still required to install the Display Patch first! And some sort Internet connection is obviously needed as well. The option just triggers the wget command from the RetroFlag site.
Note: This option will only appear in the menu when the Shutdown script is not installed.
Installation/Usage:
Save the script with a Name without Spaces and the suffix .sh
Example:AdvancedSettings.sh
And I suggest copying it into the retropiemenu folder. Then it will be available from the Retropie Menu in EmulationStation. If not, make sure to disable the Parse Gamelist option in EmulationStation.
The menu is hopefully self explaing and selecting an option will ask for confirmation.
Important: Most options require a reboot or at least a restart of EmulationStation, that's why there is also an option to reboot in the menu.Feature Plans:
- Add an option to (partially) disable the Shutdown script. Because it also checks if the Dock is used, it is not possible to use the SD card in a different Pi. For some one like me, who's doesn't own the Dock, that might be interesting. But since I enjoy the handheld, it's not a priority right now.
I'm open for any other suggestions and feedback.
#!/bin/bash SCRIPTNAME="$(basename "${0}" | sed 's/\(.*\)\..*/\1/')" SCRIPTDIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) #### Set config paths CONFFILE="/boot/config.txt" AOCONFFILE="/etc/asound.conf" APCONFFILE="${HOME}/.alsoftrc" RACONFFILE="/opt/retropie/configs/all/retroarch.cfg" ASCONFFILE="/opt/retropie/configs/all/autostart.sh" ESCONFFILE="/opt/retropie/configs/all/emulationstation/es_settings.cfg" RCCONFFILE="/etc/rc.local" ##### Basic Variables DSHORT="--clear --title ${SCRIPTNAME} --backtitle ${SCRIPTNAME} --no-collapse --colors --stdout" ###### Functions #### Main Menu function do_menu(){ while true; do do_status DOPTIO=(- "\Z1-- config.txt -- \Zn" 1 "Toggle BlueTooth: ${CBSTATUS}" 2 "Toggle WiFi: ${CWSTATUS}" - "\Z1-- Audio -- \Zn" 3 "Switch Audio to: ${AASTATUS}" 4 "Toggle Ports Audio Fix: ${APSTATUS}" - "\Z1-- EmulationStation -- \Zn" 5 "Toggle Splash: ${ASSTATUS}" 6 "Toggle Exit ES: ${AESTATUS}" 7 "UI Mode: ${EUSTATUS}" - "\Z1-- RetroArch -- \Zn" 8 "Toggle Controller Notification: ${RCSTATUS}") do_gpi2case DOPTIO+=(- "\Z1-- - -- \Zn" 0 "Reboot System") DMENU=$(dialog ${DSHORT} --default-item "1" --cancel-label Exit --menu " Select option:" 23 60 18 "${DOPTIO[@]}"); RC=$? case $RC in 1) exit;; 255) exit 1;; esac #0=Ok,1=Cancel,2=Help,3=Extra,4=ItemHelp,255=Escape case $DMENU in 1) do_ask "Turn BlueTooth: ${CBSTATUS}?" "do_togglecfgtxt bt" "BlueTooth is now: ${CBSTATUS}";; 2) do_ask "Turn WiFi: ${CWSTATUS}?" "do_togglecfgtxt wifi" "WiFi is now: ${CWSTATUS}";; 3) do_ask "Switch Audio to: ${AASTATUS}?" "do_switchaudio" "Audio is now: ${AASTATUS}";; 4) do_ask "Turn Ports Audio Fix: ${APSTATUS}?" "do_portsaudio" "Ports Audio Fix is now: ${APSTATUS}";; 5) do_ask "Turn ES Splash: ${ASSTATUS}?" "do_toggleessplash" "ES Splash x is now: ${ASSTATUS}";; 6) do_ask "Turn ES Exit: ${AESTATUS}?" "do_toggleesexit" "ES Exit is now: ${AESTATUS}";; 7) do_ask "Set ES UI Mode to: ${EUSTATUS}?" "do_uifull" "ES UI Mode is now: ${EUSTATUS}";; 8) do_ask "Turn Controller Notifications: ${RCSTATUS}?" "do_togglera" "Controller Notifications are now: ${RCSTATUS}";; 9) do_ask "Install SafeShutdown?" "wget -O - 'https://raw.githubusercontent.com/RetroFlag/GPiCase2-Script/main/retropie_install_gpi2.sh' | sudo bash" "SafeShutdown installed";; 0) sudo reboot;; *) ;; esac done } #### Ask before function do_ask(){ while true; do ASK=$(dialog ${DSHORT} --defaultno --yesno "\n ${1}" 7 60); RC=$? case $RC in 0) ${2} && dialog ${DSHORT} --msgbox "\n ${3}.\n\n Reboot to apply changes!" 9 60; break;; 1) break;; 255) exit 1;; esac done } #### Check for entrys or create them function do_check() { if ! grep -q "dtoverlay=disable-bt" "${CONFFILE}"; then echo '#dtoverlay=disable-bt' | sudo tee -a "${CONFFILE}" >/dev/null; fi if ! grep -q "dtoverlay=disable-wifi" "${CONFFILE}"; then echo '#dtoverlay=disable-wifi' | sudo tee -a "${CONFFILE}" >/dev/null; fi if ! grep -q "notification_show_autoconfig" "${RACONFFILE}"; then echo 'notification_show_autoconfig = "true"' | sudo tee -a "${RACONFFILE}" >/dev/null; fi } #### Get Status function do_status() { if grep -q "^#dtoverlay=disable-bt" "${CONFFILE}"; then CBSTATUS="OFF"; else CBSTATUS="ON"; fi if grep -q "^#dtoverlay=disable-wifi" "${CONFFILE}"; then CWSTATUS="OFF"; else CWSTATUS="ON"; fi if [ -e "${AOCONFFILE}" ]; then AASTATUS="STEREO (Headphones)"; else AASTATUS="MONO (Speaker)"; fi if [ -e "${APCONFFILE}" ]; then APSTATUS="OFF"; else APSTATUS="ON"; fi if grep -q "no-splash" "${ASCONFFILE}"; then ASSTATUS="ON"; else ASSTATUS="OFF"; fi if grep -q "no-exit" "${ASCONFFILE}"; then AESTATUS="ON"; else AESTATUS="OFF"; fi if grep -q "UIMode.*Full" "${ESCONFFILE}"; then EUSTATUS="Ok"; else EUSTATUS="Full"; fi if grep -q 'notification_show_autoconfig = "true"' "${RACONFFILE}"; then RCSTATUS="OFF"; else RCSTATUS="ON"; fi } #### config.txt Toggle function do_togglecfgtxt() { if grep -q "^#dtoverlay=disable-${1}" "${CONFFILE}"; then sed "s|#dtoverlay=disable-${1}|dtoverlay=disable-${1}|" <"${CONFFILE}" >"${HOME}/config.sed" && sudo mv "${HOME}/config.sed" "${CONFFILE}" else sed "s|^dtoverlay=disable-${1}|#dtoverlay=disable-${1}|" <"${CONFFILE}" >"${HOME}/config.sed" && sudo mv "${HOME}/config.sed" "${CONFFILE}" fi } #### Switch Audio function do_switchaudio() { if [ -e "${AOCONFFILE}" ]; then sudo rm -f "${AOCONFFILE}" else echo '# convert stereo to mono RIGHT output' > "${HOME}/asound.conf" echo 'pcm.monocard{' >> "${HOME}/asound.conf" echo ' slave.pcm "hw:0"' >> "${HOME}/asound.conf" echo ' slave.channels 2' >> "${HOME}/asound.conf" echo ' type route' >> "${HOME}/asound.conf" echo ' ttable {' >> "${HOME}/asound.conf" echo ' # Copy both input channels to output channel 1 (Right).' >> "${HOME}/asound.conf" echo ' 0.1 1' >> "${HOME}/asound.conf" echo ' 1.1 1' >> "${HOME}/asound.conf" echo ' # Copy both input channels to output channel 0 (Left).' >> "${HOME}/asound.conf" echo ' 0.0 1' >> "${HOME}/asound.conf" echo ' 1.0 1' >> "${HOME}/asound.conf" echo ' }' >> "${HOME}/asound.conf" echo '}' >> "${HOME}/asound.conf" echo '' >> "${HOME}/asound.conf" echo 'pcm.!default monocard' >> "${HOME}/asound.conf" sudo mv "${HOME}/asound.conf" "${AOCONFFILE}" fi } #### Ports Audio Fix function do_portsaudio() { if [ -e "${APCONFFILE}" ]; then sudo rm -f "${APCONFFILE}" else echo '[alsa]' > "${APCONFFILE}"; echo 'mmap = false' >> "${APCONFFILE}" fi } #### ES Splash Toggle function do_toggleessplash() { if grep -q "no-splash" "${ASCONFFILE}"; then sed "s| --no-splash | |" <"${ASCONFFILE}" >"${HOME}/config.sed" && sudo mv "${HOME}/config.sed" "${ASCONFFILE}" else sed "s|emulationstation|emulationstation --no-splash|" <"${ASCONFFILE}" >"${HOME}/config.sed" && sudo mv "${HOME}/config.sed" "${ASCONFFILE}" fi } #### ES Exit Toggle function do_toggleesexit() { if grep -q "no-exit" "${ASCONFFILE}"; then sed "s| --no-exit | |" <"${ASCONFFILE}" >"${HOME}/config.sed" && sudo mv "${HOME}/config.sed" "${ASCONFFILE}" else sed "s|emulationstation|emulationstation --no-exit|" <"${ASCONFFILE}" >"${HOME}/config.sed" && sudo mv "${HOME}/config.sed" "${ASCONFFILE}" fi } #### ES UI Full function do_uifull() { if grep -q "UIMode.*Full" "${ESCONFFILE}"; then sleep 1; else sed 's|<string name="UIMode" value=".*$|<string name="UIMode" value="Full" />|' <"${ESCONFFILE}" >"${HOME}/config.sed" && sudo mv "${HOME}/config.sed" "${ESCONFFILE}" fi } #### config.txt Toggle function do_togglera() { if grep -q 'notification_show_autoconfig = "true"' "${RACONFFILE}"; then sed 's|notification_show_autoconfig = "true"|notification_show_autoconfig = "false"|' <"${RACONFFILE}" >"${HOME}/raconfig.sed" && sudo mv "${HOME}/raconfig.sed" "${RACONFFILE}" else sed 's|notification_show_autoconfig = "false"|notification_show_autoconfig = "true"|' <"${RACONFFILE}" >"${HOME}/raconfig.sed" && sudo mv "${HOME}/raconfig.sed" "${RACONFFILE}" fi } #### Get Status function do_gpi2case() { if [ ! -e "/opt/RetroFlag/SafeShutdown.py" ]; then DOPTIO+=(- "\Z1-- GPI2 Case -- \Zn" 9 "Install SafeShutdown") fi } do_menu
-
I get a lot of errors trying to run this script, syntax errors and unexpected tokens. We're just copying what you posted into a .sh file?
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.