From 6ac3b9b139c9748ffe45c93c9161592dfda193d5 Mon Sep 17 00:00:00 2001 From: Zile995 Date: Sun, 1 Oct 2023 14:47:37 +0200 Subject: [PATCH] scripts: config: Do not return immediately if there is no default splash Signed-off-by: Zile995 --- scripts/config | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/scripts/config b/scripts/config index 5796b71..686dbdc 100755 --- a/scripts/config +++ b/scripts/config @@ -82,22 +82,32 @@ _get_sbsign_property() { echo "$value" } +# Checks if the splash file is a BMP file +_is_bmp() { + local splash="$1" + # If the the splash exists and is a BMP file, return + if [[ -e $splash && $(file -b --mime-type "$splash") == 'image/bmp' ]]; then return; fi + false +} + +# Returns the splash file path _get_splash_path() { # Set the default arch linux splash local default_splash=/usr/share/systemd/bootctl/splash-arch.bmp - # If the default arch splash doesn't exist, return and do not use splash - [[ ! -e $default_splash ]] && return - # If config file doesn't exist, use the default arch linux splash - [[ $config_valid -eq 1 ]] && echo "$default_splash" && return + + # If the config file doesn't exist or is not valid, use the default arch linux splash + if [[ $config_valid -eq 1 ]] && _is_bmp "$default_splash"; then + echo "$default_splash" && return + fi # Otherwise use the splash path from the config file local splash="$(yq '.splash' "$CONFIG")" + # If splash path is not specified or does not exist, use the default arch linux splash if [[ $splash == null ]] || [[ ! -e $splash ]]; then splash="$default_splash" fi + # Finally, return the splash path if the splash is a BMP file - if [[ $(file -b --mime-type "$splash") == 'image/bmp' ]]; then - echo "$splash" - fi + if _is_bmp "$splash"; then echo "$splash"; fi }