diff --git a/0-setup-linux.sh b/0-setup-linux.sh index 44699b7..6a4e9db 100755 --- a/0-setup-linux.sh +++ b/0-setup-linux.sh @@ -28,7 +28,7 @@ color_reset() { printf '%b' "$RESET"; } ########################## # Script Version Selection ########################## -SCRIPT_VERSION="${SCRIPT_VERSION:-v1}" # Default to v1 if not set +SCRIPT_VERSION="${SCRIPT_VERSION:-v2}" # Default to v2 if not set echo echo "Select script version:" diff --git a/v2/debian-full.sh b/v2/debian-full.sh index 9c7ab9e..2362aa0 100755 --- a/v2/debian-full.sh +++ b/v2/debian-full.sh @@ -129,65 +129,51 @@ if [[ "${DE}" == "xfce" || "${DDE}" == "xfce" ]]; then SOURCE_DIR="$SCRIPT_DIR/config-files/debian" DEST_DIR="$HOME" - # Variable to track if Xfce was running *before* we killed the processes - XFCE_WAS_RUNNING=0 - - # 1. Check if the source directory exists + # Check source directory if [ ! -d "$SOURCE_DIR" ]; then say_red "Error: Source directory '$SOURCE_DIR' not found. Aborting." exit 1 fi - # 2. Aggressively Stop Xfce Processes if XFCE active - if pgrep -x "xfce4-panel" > /dev/null; then - # Store the state that Xfce was running + # Detect if XFCE is running + XFCE_WAS_RUNNING=0 + if pgrep -x "xfce4-panel" >/dev/null || pgrep -x "xfconfd" >/dev/null; then XFCE_WAS_RUNNING=1 - - say_yellow "Stopping Xfce Panel and Configuration Daemon to prevent settings overwrite..." - # Kill the panel, configuration daemon, and window manager - pkill xfce4-panel - pkill xfconfd - pkill xfwm4 + say_yellow "Stopping all XFCE components..." + pkill -x xfce4-panel + pkill -x xfconfd + pkill -x xfwm4 + pkill -x xfsettingsd + pkill -x xfce4-session sleep 1 fi - # 3. Copy files from source to destination recursively (Unconditional) - say_yellow "Copying all files and directories (including hidden ones) from $SOURCE_DIR to $DEST_DIR" + # Clean cache before copying + say_yellow "Removing old Xfce session cache..." + rm -rf "$HOME/.cache/sessions" - # Enable dotglob so that '*' matches files starting with '.' (like .config) + # Copy configs (including hidden) + say_yellow "Copying configuration files..." shopt -s dotglob - - # Copy the entire directory structure into $HOME, merging files where necessary. cp -vrf "$SOURCE_DIR"/* "$DEST_DIR"/ - - # Disable dotglob to revert the shell behavior shopt -u dotglob - say_green "Configurations copied to disk." + # Ensure ownership + chown -R "$(id -u):$(id -g)" "$DEST_DIR/.config/xfce4" - # 4. Cleanup and Restart Xfce processes to load the new configuration + say_green "Configuration files copied." + + # Restart Xfce components only if it was running before if [ "$XFCE_WAS_RUNNING" -eq 1 ]; then - say_bold "Xfce was detected. Applying configuration changes immediately." - - # CRITICAL FIX: Delete the session cache to prevent Xfce from restoring old settings - # This forces the session manager to read the new configuration files. - say_yellow "Clearing Xfce session cache to force a fresh configuration load..." - rm -rf "$HOME/.cache/sessions/" - - # Restart Xfce processes to load the new configuration from the copied files - say_cyan "Restarting Xfce environment components..." - - # Restart the Window Manager first - xfwm4 --replace & disown - - # Restart the Panel - xfce4-panel & disown - - say_green "Xfce configuration successfully loaded and applied." - say_cyan "Panel and Window Manager restarted." + say_bold "Restarting Xfce to apply new configuration..." + nohup xfconfd & + nohup xfwm4 --replace & + nohup xfce4-panel & + nohup xfsettingsd & + disown + say_green "XFCE configuration applied successfully." else - say_cyan "Xfce Panel was not running. Configurations copied to $HOME." - say_cyan "Please log out and log back in to fully apply the Xfce configuration changes." + say_cyan "XFCE was not running. Please log out and back in to load new settings." fi