diff --git a/emu-configs/defaults/retrodeck/retrodeck.cfg b/emu-configs/defaults/retrodeck/retrodeck.cfg index 1897eecd..6c85592b 100644 --- a/emu-configs/defaults/retrodeck/retrodeck.cfg +++ b/emu-configs/defaults/retrodeck/retrodeck.cfg @@ -14,8 +14,10 @@ sdcard=/run/media/mmcblk0p1 power_user_warning=true desktop_mode_warning=true -network_features=false +update_check=false update_repo=RetroDECK +update_ignore= +cloud_saves=false multi_user_mode=false ask_default_user=true default_user= diff --git a/functions.sh b/functions.sh index 249b2aea..e2dc3843 100644 --- a/functions.sh +++ b/functions.sh @@ -635,11 +635,44 @@ check_network_connectivity() { check_for_version_update() { # This function will perform a basic online version check and alert the user if there is a new version available. - local current_version=$(sed -e 's/[\.a-z]//g' <<< $version) - local online_version=$(curl --silent "https://api.github.com/repos/XargonWan/$update_repo/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | sed -e 's/[\.a-z]//g') + local online_version=$(curl --silent "https://api.github.com/repos/XargonWan/$update_repo/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') - if [[ $current_version -le $online_version ]]; then - echo "There is a new version online!" + if [[ ! "$update_ignore" == "$online_version" ]] + if [[ "$update_repo" == "RetroDECK" ]] && [[ $(sed -e 's/[\.a-z]//g' <<< $version) -le $(sed -e 's/[\.a-z]//g' <<< $online_version) ]]; then + choice=$(zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --ok-label="Yes" --extra-button="No" --extra-button="Ignore this version" \ + --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ + --title "RetroDECK Update Available" \ + --text="There is a new version of RetroDECK available!\n\nIf you would like to update to the new version now, click \"Yes\". If you would like to skip reminders about this version, click \"Ignore this version\".\nYou will be reminded again at the next version update.\n\nIf you would like to disable these update notifications entirely, disable Online Update Checks in the Configurator.") + rc=$? # Capture return code, as "Yes" button has no text value + if [[ $rc == "1" ]]; then # If any button other than "Yes" was clicked + if [[ $choice == "Ignore this version" ]]; then + set_setting_value $rd_conf "update_ignore" "$online_version" retrodeck # Store version to ignore for future checks + fi + else # User clicked "Yes" + configurator_generic_dialog "The update process may take several minutes.\n\nAfter the update is complete, RetroDECK will close. When you run it again you will be using the latest version." + flatpak-spawn --host flatpak update --noninteractive -y net.retrodeck.retrodeck + exit 1 + fi + elif [[ "$update_repo" == "RetroDECK-cooker" ]] && [[ ! $current_version == $online_version ]]; then + choice=$(zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --ok-label="Yes" --extra-button="No" --extra-button="Ignore this version" \ + --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ + --title "RetroDECK Update Available" \ + --text="There is a more recent build of the RetroDECK cooker branch. Would you like to update to it? If you would like to skip reminders about this version, click \"Ignore this version\". You will be reminded again at the next version update.\n\nIf you would like to disable these update notifications entirely, disable Online Update Checks in the Configurator.") + rc=$? # Capture return code, as "Yes" button has no text value + if [[ $rc == "1" ]]; then # If any button other than "Yes" was clicked + if [[ $choice == "Ignore this version" ]]; then + set_setting_value $rd_conf "update_ignore" "$online_version" retrodeck # Store version to ignore for future checks. + fi + else # User clicked "Yes" + configurator_generic_dialog "The update process may take several minutes.\n\nAfter the update is complete, RetroDECK will close. When you run it again you will be using the latest version." + local latest_cooker_download=$(curl --silent https://api.github.com/repos/XargonWan/$update_repo/releases/latest | grep '"browser_download_url":' | sed -E 's/.*"([^"]+)".*/\1/') + mkdir -p "$rdhome/RetroDECK_Updates" + wget -P "$rdhome/RetroDECK_Updates" $latest_cooker_download + flatpak-spawn --host flatpak install --user --bundle --noninteractive -y "$rdhome/RetroDECK_Updates/RetroDECK.flatpak" + rm -f "$rdhome/RetroDECK_Updates" # Cleanup old bundles to save space + exit 1 + fi + fi fi } @@ -1899,6 +1932,20 @@ configurator_generic_dialog() { --text="$1" } +configurator_generic_question_dialog() { + # This dialog provides a generic dialog for getting a response from a user. + # USAGE: $(configurator_generic_question_dialog "title text" "action text") + # This function will return a "true" if the user clicks "Yes", and "false" if they click "No". + choice=$(zenity --title "RetroDECK - $1" --question --no-wrap --cancel-label="No" --ok-label="Yes" \ + --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ + --text="$2") + if [[ $? == "0" ]]; then + echo "true" + else + echo "false" + fi +} + configurator_destination_choice_dialog() { # This dialog is for making things easy for new users to move files to common locations. Gives the options for "Internal", "SD Card" and "Custom" locations. # USAGE: $(configurator_destination_choice_dialog "folder being moved" "action text") diff --git a/net.retrodeck.retrodeck.yml b/net.retrodeck.retrodeck.yml index 89dd8851..4c5027df 100644 --- a/net.retrodeck.retrodeck.yml +++ b/net.retrodeck.retrodeck.yml @@ -24,6 +24,7 @@ finish-args: - --talk-name=org.freedesktop.ScreenSaver - --talk-name=org.freedesktop.PowerManagement.Inhibit - --talk-name=org.freedesktop.login1.Manager + - --talk-name=org.freedesktop.Flatpak - --filesystem=xdg-run/app/com.discordapp.Discord:create # Yuzu # - --filesystem=home:ro # This may break Yuzu, let's see diff --git a/retrodeck.sh b/retrodeck.sh index c11005aa..3235898d 100644 --- a/retrodeck.sh +++ b/retrodeck.sh @@ -118,6 +118,11 @@ fi desktop_mode_warning +# Check if there is a new version of RetroDECK available, if update_check=true in retrodeck.cfg and there is network connectivity available. +if [[ check_network_connectivity == "true" ]] && [[ $update_check == "true" ]]; then + check_for_version_update +fi + # Normal Startup start_retrodeck \ No newline at end of file diff --git a/tools/configurator.sh b/tools/configurator.sh index 1f6be9f2..1fd1a1f2 100644 --- a/tools/configurator.sh +++ b/tools/configurator.sh @@ -286,6 +286,7 @@ configurator_power_user_warning_dialog() { configurator_welcome_dialog elif [[ $choice == "Never show this again" ]]; then set_setting_value $rd_conf "power_user_warning" "false" retrodeck # Store desktop mode warning variable for future checks + source $rd_conf configurator_power_user_changes_dialog fi fi @@ -874,6 +875,62 @@ configurator_move_dialog() { fi } +configurator_online_update_setting_dialog() { + if [[ $(get_setting_value $rd_conf "update_check" retrodeck) == "true" ]]; then + zenity --question \ + --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ + --title "RetroDECK Configurator - RetroDECK Online Update Check" \ + --text="Online update checks for RetroDECK are currently enabled.\n\nDo you want to disable them?" + + if [ $? == 0 ] # User clicked "Yes" + then + set_setting_value $rd_conf "update_check" "false" retrodeck + else # User clicked "Cancel" + configurator_developer_dialog + fi + else + zenity --question \ + --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ + --title "RetroDECK Configurator - RetroDECK Online Update Check" \ + --text="Online update checks for RetroDECK are currently disabled.\n\nDo you want to enable them?" + + if [ $? == 0 ] # User clicked "Yes" + then + set_setting_value $rd_conf "update_check" "true" retrodeck + else # User clicked "Cancel" + configurator_developer_dialog + fi + fi +} + +configurator_online_update_setting_dialog() { + if [[ $(get_setting_value $rd_conf "update_repo" retrodeck) == "RetroDECK" ]]; then + zenity --question \ + --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ + --title "RetroDECK Configurator - RetroDECK Change Update Branch" \ + --text="You are currently on the production branch of RetroDECK updates. Would you like to switch to the cooker branch?\n\nAfter installing a cooker build, you may need to remove the \"stable\" branch install of RetroDECK to avoid overlap." + + if [ $? == 0 ] # User clicked "Yes" + then + set_setting_value $rd_conf "update_repo" "RetroDECK-cooker" retrodeck + else # User clicked "Cancel" + configurator_developer_dialog + fi + else + zenity --question \ + --no-wrap --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ + --title "RetroDECK Configurator - RetroDECK Change Update Branch" \ + --text="You are currently on the cooker branch of RetroDECK updates. Would you like to switch to the production branch?\n\n" + + if [ $? == 0 ] # User clicked "Yes" + then + set_setting_value $rd_conf "update_repo" "RetroDECK" retrodeck + else # User clicked "Cancel" + configurator_developer_dialog + fi + fi +} + configurator_retrodeck_multiuser_dialog() { if [[ $(get_setting_value $rd_conf "multi_user_mode" retrodeck) == "true" ]]; then zenity --question \ @@ -906,7 +963,9 @@ configurator_developer_dialog() { choice=$(zenity --list --title="RetroDECK Configurator Utility - Change Options" --cancel-label="Back" \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" --width=1200 --height=720 \ --column="Choice" --column="Action" \ - "Change Multi-user mode" "Enable or disable multi-user support" ) + "Change Multi-user mode" "Enable or disable multi-user support" \ + "Change Update Channel" "Change between normal and cooker builds" \ + "Change Update Check Setting" "Enable or disable online checks for new versions of RetroDECK" ) case $choice in @@ -914,6 +973,14 @@ configurator_developer_dialog() { configurator_retrodeck_multiuser_dialog ;; + "Change Update Channel" ) + configurator_retrodeck_multiuser_dialog + ;; + + "Change Update Check Setting" ) + configurator_retrodeck_multiuser_dialog + ;; + "" ) # No selection made or Back button clicked configurator_welcome_dialog ;;