From 8e972b6c13f757ace73854edb0077ecfd6d04ddd Mon Sep 17 00:00:00 2001 From: JaKooLit Date: Sun, 16 Feb 2025 13:13:21 +0900 Subject: [PATCH] fixed sddm theme applying --- install-scripts/sddm_theme.sh | 42 ++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/install-scripts/sddm_theme.sh b/install-scripts/sddm_theme.sh index 472d2c9..742f1e6 100755 --- a/install-scripts/sddm_theme.sh +++ b/install-scripts/sddm_theme.sh @@ -48,13 +48,43 @@ if git clone --depth 1 "$source_theme" "$theme_name"; then # Move cloned theme to the themes directory sudo mv "$theme_name" "/usr/share/sddm/themes/$theme_name" 2>&1 | tee -a "$LOG" - # Set up new theme - echo -e "${NOTE} Setting up the login screen." - sddm_conf_dir=/etc/sddm.conf.d - [ ! -d "$sddm_conf_dir" ] && { printf "$CAT - $sddm_conf_dir not found, creating...\n"; sudo mkdir -p "$sddm_conf_dir" 2>&1 | tee -a "$LOG"; } + # setting up SDDM theme + sddm_conf_dir="/etc/sddm.conf.d" + BACKUP_SUFFIX=".bak" - # Configure theme settings - echo -e "[Theme]\nCurrent=$theme_name" | sudo tee "$sddm_conf_dir/theme.conf.user" >> "$LOG" + echo -e "${NOTE} Setting up the login screen." | tee -a "$LOG" + + if [ -d "$sddm_conf_dir" ]; then + # If the directory exists, backup present files + echo "Backing up files in $sddm_conf_dir" | tee -a "$LOG" + for file in "$sddm_conf_dir"/*; do + if [ -f "$file" ]; then + # not change the backed up files + if [[ "$file" == *$BACKUP_SUFFIX ]]; then + echo "Skipping backup file: $file" | tee -a "$LOG" + continue + fi + + # Backup each original file + sudo cp "$file" "$file$BACKUP_SUFFIX" 2>&1 | tee -a "$LOG" + echo "Backup created for $file" | tee -a "$LOG" + + # editing present files in "/etc/sddm.conf.d" + if grep -q '^[[:space:]]*Current=' "$file"; then + sudo sed -i 's/^[[:space:]]*Current=/#&/' "$file" 2>&1 | tee -a "$LOG" + sudo sed -i "s/^[[:space:]]*#Current=.*/Current=$theme_name/" "$file" 2>&1 | tee -a "$LOG" + echo "Updated theme in $file" | tee -a "$LOG" + fi + fi + done + else + # If the directory doesn't exist, create it and set up the new theme + echo "$CAT - $sddm_conf_dir not found, creating..." | tee -a "$LOG" + sudo mkdir -p "$sddm_conf_dir" 2>&1 | tee -a "$LOG" + + echo -e "[Theme]\nCurrent=$theme_name" | sudo tee "$sddm_conf_dir/theme.conf.user" 2>&1 | tee -a "$LOG" + echo "Created and configured $sddm_conf_dir/theme.conf.user with theme $theme_name" | tee -a "$LOG" + fi # Replace current background from assets sudo cp -r assets/sddm.png "/usr/share/sddm/themes/$theme_name/backgrounds/default" 2>&1 | tee -a "$LOG"