diff --git a/automation_tools/appdata_management.sh b/automation_tools/appdata_management.sh index f615b1ae..9eb2ba4e 100755 --- a/automation_tools/appdata_management.sh +++ b/automation_tools/appdata_management.sh @@ -4,7 +4,6 @@ # This script is getting the latest release notes from the wiki and add them to the appdata source automation_tools/version_extractor.sh -source /app/libexec/logger.sh # Fetch appdata version appdata_version=$(fetch_appdata_version) diff --git a/emu-configs/gzdoom/gzdoom.sh b/emu-configs/gzdoom/gzdoom.sh index 620b809f..1b999575 100644 --- a/emu-configs/gzdoom/gzdoom.sh +++ b/emu-configs/gzdoom/gzdoom.sh @@ -1,7 +1,5 @@ #!/bin/bash -source /app/libexec/logger.sh - # Define the IWAD files list IWAD_FILES=("DOOM1.WAD" "DOOM.WAD" "DOOM2.WAD" "DOOM2F.WAD" "DOOM64.WAD" "TNT.WAD" "PLUTONIA.WAD" "HERETIC1.WAD" "HERETIC.WAD" "HEXEN.WAD" "HEXDD.WAD" diff --git a/functions/050_save_migration.sh b/functions/050_save_migration.sh index f7a1f108..b75672b4 100644 --- a/functions/050_save_migration.sh +++ b/functions/050_save_migration.sh @@ -1,7 +1,5 @@ #!/bin/bash -source /app/libexec/logger.sh - save_migration() { # Finding existing ROMs folder if [ -d "$default_sd/retrodeck" ] diff --git a/functions/checks.sh b/functions/checks.sh index 16414c57..39719a02 100644 --- a/functions/checks.sh +++ b/functions/checks.sh @@ -1,7 +1,5 @@ #!/bin/bash -source /app/libexec/logger.sh - check_network_connectivity() { # This function will do a basic check for network availability and return "true" if it is working. # USAGE: if [[ $(check_network_connectivity) == "true" ]]; then diff --git a/functions/compression.sh b/functions/compression.sh index 17120f25..5b990c3e 100644 --- a/functions/compression.sh +++ b/functions/compression.sh @@ -1,7 +1,5 @@ #!/bin/bash -source /app/libexec/logger.sh - compress_game() { # Function for compressing one or more files to .chd format # USAGE: compress_game $format $full_path_to_input_file $system(optional) diff --git a/functions/dialogs.sh b/functions/dialogs.sh index af005e63..c98c2ac8 100644 --- a/functions/dialogs.sh +++ b/functions/dialogs.sh @@ -162,6 +162,8 @@ changelog_dialog() { # The function also accepts "all" as a version, and will print the entire changelog # USAGE: changelog_dialog "version" + log d "Showing changelog dialog" + if [[ "$1" == "all" ]]; then xml sel -t -m "//release" -v "concat('RetroDECK version: ', @version)" -n -v "description" -n $rd_appdata | awk '{$1=$1;print}' | sed -e '/./b' -e :n -e 'N;s/\n$//;tn' > "/var/config/retrodeck/changelog.txt" @@ -186,6 +188,8 @@ get_cheevos_token_dialog() { # This function will return a RetroAchvievements token from a valid username and password, will return "login failed" otherwise # USAGE: get_cheevos_token_dialog + log d "Opening RetroAchievements dialog" + local cheevos_info=$(zenity --forms --title="Cheevos" \ --text="Username and password." \ --separator="^" \ @@ -211,15 +215,20 @@ desktop_mode_warning() { # USAGE: desktop_mode_warning if [[ $(check_desktop_mode) == "true" && $desktop_mode_warning == "true" ]]; then + local message='You appear to be running RetroDECK in the Steam Deck'\''s Desktop mode!\n\nSome functions of RetroDECK may not work properly in Desktop mode, such as the Steam Deck'\''s normal controls.\n\nRetroDECK is best enjoyed in Game mode!\n\nDo you still want to proceed?' + log i "Showing message:\n$message" choice=$(zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --ok-label="Yes" --extra-button="No" --extra-button="Never show this again" \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ --title "RetroDECK Desktop Mode Warning" \ - --text="You appear to be running RetroDECK in the Steam Deck's Desktop mode!\n\nSome functions of RetroDECK may not work properly in Desktop mode, such as the Steam Deck's normal controls.\n\nRetroDECK is best enjoyed in Game mode!\n\nDo you still want to proceed?") + --text="$message") rc=$? # Capture return code, as "Yes" button has no text value if [[ $rc == "1" ]]; then # If any button other than "Yes" was clicked + log i "Selected: \"Yes\"" if [[ $choice == "No" ]]; then + log i "Selected: \"No\"" exit 1 elif [[ $choice == "Never show this again" ]]; then + log i "Selected: \"Never show this again\"" set_setting_value $rd_conf "desktop_mode_warning" "false" retrodeck "options" # Store desktop mode warning variable for future checks fi fi @@ -233,13 +242,17 @@ low_space_warning() { if [[ $low_space_warning == "true" ]]; then local used_percent=$(df --output=pcent "$HOME" | tail -1 | tr -d " " | tr -d "%") if [[ "$used_percent" -ge 90 && -d "$HOME/retrodeck" ]]; then # If there is any RetroDECK data on the main drive to move + local message='Your main drive is over 90% full!\n\nIf your drive fills completely this can lead to data loss or system crash.\n\nPlease consider moving some RetroDECK folders to other storage locations using the Configurator.' + log i "Showing message:\n$message" choice=$(zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --ok-label="OK" --extra-button="Never show this again" \ --window-icon="/app/share/icons/hicolor/scalable/apps/net.retrodeck.retrodeck.svg" \ --title "RetroDECK Low Space Warning" \ - --text="Your main drive is over 90% full!\n\nIf your drive fills completely this can lead to data loss or system crash.\n\nPlease consider moving some RetroDECK folders to other storage locations using the Configurator.") + --text="$message") if [[ $choice == "Never show this again" ]]; then - set_setting_value $rd_conf "low_space_warning" "false" retrodeck "options" # Store low space warning variable for future checks + log i "Selected: \"Never show this again\"" + set_setting_value $rd_conf "low_space_warning" "false" retrodeck "options" # Store low space warning variable for future checks fi fi + log i "Selected: \"OK\"" fi } \ No newline at end of file diff --git a/functions/functions.sh b/functions/functions.sh index 6b1f6fdb..46c1dea4 100644 --- a/functions/functions.sh +++ b/functions/functions.sh @@ -1,7 +1,5 @@ #!/bin/bash -source /app/libexec/logger.sh - directory_browse() { # This function browses for a directory and returns the path chosen # USAGE: path_to_be_browsed_for=$(directory_browse $action_text) @@ -657,10 +655,10 @@ manage_ryujinx_keys() { echo "Created symlink: \"$symlink\"" done else - log w "No files found in $bios_folder/switch/keys. Continuing" + log w "No files found in $bios_folder/switch/keys. Continuing..." fi else - log w "Directory $bios_folder/switch/keys does not exist. Maybe Ryujinx was never run. Continuing" + log w "Directory $bios_folder/switch/keys does not exist. Maybe Ryujinx was never run. Continuing..." fi } diff --git a/functions/global.sh b/functions/global.sh index a6290f65..b313420d 100644 --- a/functions/global.sh +++ b/functions/global.sh @@ -164,8 +164,7 @@ if [[ ! -f "$rd_conf" ]]; then log i "Setting config file permissions" chmod +rw $rd_conf - log i "RetroDECK config file initialized. Contents:\n" - log i "$(cat "$rd_conf")" + log i "RetroDECK config file initialized. Contents:\n\n$(cat $rd_conf\n)" conf_read # Load new variables into memory tmplog_merger @@ -201,4 +200,4 @@ else multi_user_data_folder="$rdhome/multi-user-data" # The default location of multi-user environment profiles fi -logs_folder="$rdhome/retrodeck/logs" # The path of the logs folder, here we collect all the logs \ No newline at end of file +logs_folder="$rdhome/logs" # The path of the logs folder, here we collect all the logs \ No newline at end of file diff --git a/functions/logger.sh b/functions/logger.sh index 8708d8b3..19353180 100755 --- a/functions/logger.sh +++ b/functions/logger.sh @@ -7,12 +7,12 @@ # log e "bar" -> logs an error with message bar in the default log file retrodeck/logs/retrodeck.log # log i "par" rekku.log -> logs an information with message in the specified log file inside the logs folder retrodeck/logs/rekku.log -if [ "${log_init:-false}" = false ]; then - logs_folder=${logs_folder:-"/tmp"} - touch "$logs_folder/retrodeck.log" - # exec > >(tee "$logs_folder/retrodeck.log") 2>&1 # this is broken, creates strange artifacts and corrupts the log file - log_init=true -fi +# if [ "${log_init:-false}" = false ]; then +# logs_folder=${logs_folder:-"/tmp"} +# touch "$logs_folder/retrodeck.log" +# # exec > >(tee "$logs_folder/retrodeck.log") 2>&1 # this is broken, creates strange artifacts and corrupts the log file +# log_init=true +# fi log() { @@ -89,6 +89,10 @@ log() { echo -e "$colored_message" # Write the log message to the log file + if [ ! -f "$logfile" ]; then + echo "$timestamp [WARN] Log file not found in \"$logfile\", creating it" + touch "$logfile" + fi echo "$log_message" >> "$logfile" } @@ -96,8 +100,10 @@ log() { # This function is merging the temporary log file into the actual one tmplog_merger() { + create_dir "$logs_folder" + # Check if /tmp/retrodeck.log exists - if [ -e "/tmp/retrodeck.log" ]; then + if [ -e "/tmp/retrodeck.log" ] && [ -e "$logs_folder/retrodeck.log" ]; then # Sort both temporary and existing log files by timestamp sort -k1,1n -k2,2M -k3,3n -k4,4n -k5,5n "/tmp/retrodeck.log" "$logs_folder/retrodeck.log" > "$logs_folder/merged_logs.tmp" @@ -108,14 +114,13 @@ tmplog_merger() { # Remove the temporary file rm "/tmp/retrodeck.log" fi -} -ESDE_source_logs="/var/config/emulationstation/.emulationstation/es_log.txt" -# Check if the source file exists -if [ -e "$ESDE_source_logs" ]; then - # Create the symlink in the logs folder - ln -sf "$source_file" "$logs_folder/ES-DE.log" - log i "ES-DE log file linked to \"$logs_folder/ES-DE.log\"" -else - echo "ES-DE log file not found, not linked" -fi + local ESDE_source_logs="/var/config/ES-DE/logs/es_log.txt" + # Check if the source file exists + if [ -e "$ESDE_source_logs" ]; then + # Create the symlink in the logs folder + ln -sf "$ESDE_source_logs" "$logs_folder/ES-DE.log" + log i "ES-DE log file linked to \"$logs_folder/ES-DE.log\"" + fi + +} diff --git a/functions/multi_user.sh b/functions/multi_user.sh index 05231bc0..10fced39 100644 --- a/functions/multi_user.sh +++ b/functions/multi_user.sh @@ -1,7 +1,5 @@ #!/bin/bash -source /app/libexec/logger.sh - multi_user_set_default_dialog() { chosen_user="$1" choice=$(zenity --icon-name=net.retrodeck.retrodeck --info --no-wrap --ok-label="Yes" --extra-button="No" --extra-button="No and don't ask again" \ diff --git a/functions/patching.sh b/functions/patching.sh index e43b9507..368f6529 100644 --- a/functions/patching.sh +++ b/functions/patching.sh @@ -1,7 +1,5 @@ #!/bin/bash -source /app/libexec/logger.sh - set_setting_value() { # Function for editing settings # USAGE: set_setting_value "$setting_file" "$setting_name" "$new_setting_value" "$system" "$section_name(optional)" diff --git a/functions/post_update.sh b/functions/post_update.sh index 9449a3d5..42cfd85b 100644 --- a/functions/post_update.sh +++ b/functions/post_update.sh @@ -239,7 +239,7 @@ post_update() { # - Remove RetroDECK controller profile from existing template location # - Change section name in retrodeck.cfg for ABXY button swap preset # - Force disable global rewind in RA in prep for preset system - if [[ -f "$HOME/.steam/steam/controller_base/templates/RetroDECK_controller_config.vdf"]]; then # Only remove if file had been previously installed + if [[ -f "$HOME/.steam/steam/controller_base/templates/RetroDECK_controller_config.vdf" ]]; then # Only remove if file had been previously installed rm -f "$HOME/.steam/steam/controller_base/templates/RetroDECK_controller_config.vdf" fi sed -i 's^nintendo_button_layout^abxy_button_swap^' "$rd_conf" # This is a one-off sed statement as there are no functions for replacing section names diff --git a/retrodeck.sh b/retrodeck.sh index eab32dcf..f7edcf7c 100644 --- a/retrodeck.sh +++ b/retrodeck.sh @@ -1,7 +1,6 @@ #!/bin/bash source /app/libexec/global.sh -source /app/libexec/logger.sh # Arguments section diff --git a/tools/configurator.sh b/tools/configurator.sh index bc7d5f2a..2b1686b9 100644 --- a/tools/configurator.sh +++ b/tools/configurator.sh @@ -3,7 +3,6 @@ # VARIABLES SECTION source /app/libexec/global.sh -source /app/libexec/logger.sh # DIALOG SECTION diff --git a/tools/retrodeck_function_wrapper.sh b/tools/retrodeck_function_wrapper.sh index f266ad2c..03659d84 100644 --- a/tools/retrodeck_function_wrapper.sh +++ b/tools/retrodeck_function_wrapper.sh @@ -4,7 +4,6 @@ # USAGE: /bin/bash retrodeck_function_wrapper.sh ... source /app/libexec/global.sh -source /app/libexec/logger.sh # Check if a function was specified if [[ $# -lt 1 ]]; then