diff --git a/config/retrodeck/reference_lists/easter_egg_checklist.cfg b/config/retrodeck/reference_lists/easter_egg_checklist.cfg deleted file mode 100644 index e70139e3..00000000 --- a/config/retrodeck/reference_lists/easter_egg_checklist.cfg +++ /dev/null @@ -1,6 +0,0 @@ -1201^1231^0000^2359^rd-xmas-splash.svg -0209^0212^0000^2359^rd-lunar-dragon-splash.svg -0214^0214^0001^2359^rd-valentines-splash.svg -0304^0304^0000^2359^rd-gm-bday-splash.svg -0317^0317^0000^2359^rd-stpatricks-splash.svg -0429^0505^0000^2359^rd-kodomo-golden.svg diff --git a/config/retrodeck/reference_lists/features.json b/config/retrodeck/reference_lists/features.json index dec84bc2..c9101086 100644 --- a/config/retrodeck/reference_lists/features.json +++ b/config/retrodeck/reference_lists/features.json @@ -58,7 +58,7 @@ "enabled": false } }, - "spalsh_screens" : { + "splash_screens" : { "xmas": { "start_date": "1201", "end_date": "1231", diff --git a/functions/global.sh b/functions/global.sh index 2584aafd..5cfdf78b 100644 --- a/functions/global.sh +++ b/functions/global.sh @@ -29,7 +29,6 @@ rd_update_patch="/var/config/retrodeck/rd_update.patch" bios_checklist="$config/retrodeck/reference_lists/bios_checklist.cfg" # A config file listing BIOS file information that can be verified compression_targets="$config/retrodeck/reference_lists/compression_targets.cfg" # A config file containing supported compression types per system zip_compressable_extensions="$config/retrodeck/reference_lists/zip_compressable_extensions.cfg" # A config file containing every file extension that is allowed to be compressed to .zip format, because there are a lot! -easter_egg_checklist="$config/retrodeck/reference_lists/easter_egg_checklist.cfg" # A config file listing days and times when special splash screens should show up input_validation="$config/retrodeck/reference_lists/input_validation.cfg" # A config file listing valid CLI inputs finit_options_list="$config/retrodeck/reference_lists/finit_options_list.cfg" # A config file listing available optional installs during finit splashscreen_dir="/var/config/ES-DE/resources/graphics/extra_splashes" # The default location of extra splash screens diff --git a/functions/other_functions.sh b/functions/other_functions.sh index 4676c174..5786f8cf 100644 --- a/functions/other_functions.sh +++ b/functions/other_functions.sh @@ -572,26 +572,26 @@ deploy_helper_files() { done < "$helper_files_list" } -easter_eggs() { - # This function will replace the RetroDECK startup splash screen with a different image if the day and time match a listing in easter_egg_checklist.cfg - # The easter_egg_checklist.cfg file has the current format: $start_date^$end_date^$start_time^$end_time^$splash_file - # Ex. The line "1001^1031^0000^2359^spooky.svg" would show the file "spooky.svg" during any time of day in the month of October - # The easter_egg_checklist.cfg is read in order, so lines higher in the file will have higher priority in the event of an overlap - # USAGE: easter_eggs - current_day=$(date +"%0m%0d") # Read the current date in a format that can be calculated in ranges - current_time=$(date +"%0H%0M") # Read the current time in a format that can be calculated in ranges - if [[ ! -z $(cat $easter_egg_checklist) ]]; then - while IFS="^" read -r start_date end_date start_time end_time splash_file || [[ -n "$start_date" ]]; # Read Easter Egg checklist file and separate values - do - if [[ ! $start_date == "#"* ]] && [[ ! -z "$start_date" ]]; then - if [[ "$((10#$current_day))" -ge "$((10#$start_date))" && "$((10#$current_day))" -le "$((10#$end_date))" && "$((10#$current_time))" -ge "$((10#$start_time))" && "$((10#$current_time))" -le "$((10#$end_time))" ]]; then # If current line specified date/time matches current date/time, set $splash_file to be deployed - new_splash_file="$splashscreen_dir/$splash_file" - break - else # When there are no matches, the default splash screen is set to deploy - new_splash_file="$default_splash_file" - fi - fi - done < $easter_egg_checklist +splash_screen() { + # This function will replace the RetroDECK startup splash screen with a different image if the day and time match a listing in the JSON data. + # USAGE: splash_screen + + current_day=$(date +"%m%d") # Read the current date in a format that can be calculated in ranges + current_time=$(date +"%H%M") # Read the current time in a format that can be calculated in ranges + + # Read the JSON file and extract splash screen data using jq + splash_screen=$(jq -r --arg current_day "$current_day" --arg current_time "$current_time" ' + .splash_screens | to_entries[] | + select( + ($current_day | tonumber) >= (.value.start_date | tonumber) and + ($current_day | tonumber) <= (.value.end_date | tonumber) and + ($current_time | tonumber) >= (.value.start_time | tonumber) and + ($current_time | tonumber) <= (.value.end_time | tonumber) + ) | .value.filename' config/retrodeck/reference_lists/features.json) + + # Determine the splash file to use + if [[ -n "$splash_screen" ]]; then + new_splash_file="$splashscreen_dir/$splash_screen" else new_splash_file="$default_splash_file" fi @@ -770,7 +770,7 @@ quit_retrodeck() { } start_retrodeck() { - easter_eggs # Check if today has a surprise splashscreen and load it if so + splash_screen # Check if today has a surprise splashscreen and load it if so ponzu log i "Starting RetroDECK v$version" es-de