bug fix
This commit is contained in:
@@ -28,7 +28,7 @@ color_reset() { printf '%b' "$RESET"; }
|
|||||||
##########################
|
##########################
|
||||||
# Script Version Selection
|
# 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
|
||||||
echo "Select script version:"
|
echo "Select script version:"
|
||||||
|
|||||||
@@ -129,65 +129,51 @@ if [[ "${DE}" == "xfce" || "${DDE}" == "xfce" ]]; then
|
|||||||
SOURCE_DIR="$SCRIPT_DIR/config-files/debian"
|
SOURCE_DIR="$SCRIPT_DIR/config-files/debian"
|
||||||
DEST_DIR="$HOME"
|
DEST_DIR="$HOME"
|
||||||
|
|
||||||
# Variable to track if Xfce was running *before* we killed the processes
|
# Check source directory
|
||||||
XFCE_WAS_RUNNING=0
|
|
||||||
|
|
||||||
# 1. Check if the source directory exists
|
|
||||||
if [ ! -d "$SOURCE_DIR" ]; then
|
if [ ! -d "$SOURCE_DIR" ]; then
|
||||||
say_red "Error: Source directory '$SOURCE_DIR' not found. Aborting."
|
say_red "Error: Source directory '$SOURCE_DIR' not found. Aborting."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 2. Aggressively Stop Xfce Processes if XFCE active
|
# Detect if XFCE is running
|
||||||
if pgrep -x "xfce4-panel" > /dev/null; then
|
XFCE_WAS_RUNNING=0
|
||||||
# Store the state that Xfce was running
|
if pgrep -x "xfce4-panel" >/dev/null || pgrep -x "xfconfd" >/dev/null; then
|
||||||
XFCE_WAS_RUNNING=1
|
XFCE_WAS_RUNNING=1
|
||||||
|
say_yellow "Stopping all XFCE components..."
|
||||||
say_yellow "Stopping Xfce Panel and Configuration Daemon to prevent settings overwrite..."
|
pkill -x xfce4-panel
|
||||||
# Kill the panel, configuration daemon, and window manager
|
pkill -x xfconfd
|
||||||
pkill xfce4-panel
|
pkill -x xfwm4
|
||||||
pkill xfconfd
|
pkill -x xfsettingsd
|
||||||
pkill xfwm4
|
pkill -x xfce4-session
|
||||||
sleep 1
|
sleep 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 3. Copy files from source to destination recursively (Unconditional)
|
# Clean cache before copying
|
||||||
say_yellow "Copying all files and directories (including hidden ones) from $SOURCE_DIR to $DEST_DIR"
|
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
|
shopt -s dotglob
|
||||||
|
|
||||||
# Copy the entire directory structure into $HOME, merging files where necessary.
|
|
||||||
cp -vrf "$SOURCE_DIR"/* "$DEST_DIR"/
|
cp -vrf "$SOURCE_DIR"/* "$DEST_DIR"/
|
||||||
|
|
||||||
# Disable dotglob to revert the shell behavior
|
|
||||||
shopt -u dotglob
|
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
|
if [ "$XFCE_WAS_RUNNING" -eq 1 ]; then
|
||||||
say_bold "Xfce was detected. Applying configuration changes immediately."
|
say_bold "Restarting Xfce to apply new configuration..."
|
||||||
|
nohup xfconfd &
|
||||||
# CRITICAL FIX: Delete the session cache to prevent Xfce from restoring old settings
|
nohup xfwm4 --replace &
|
||||||
# This forces the session manager to read the new configuration files.
|
nohup xfce4-panel &
|
||||||
say_yellow "Clearing Xfce session cache to force a fresh configuration load..."
|
nohup xfsettingsd &
|
||||||
rm -rf "$HOME/.cache/sessions/"
|
disown
|
||||||
|
say_green "XFCE configuration applied successfully."
|
||||||
# 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."
|
|
||||||
else
|
else
|
||||||
say_cyan "Xfce Panel was not running. Configurations copied to $HOME."
|
say_cyan "XFCE was not running. Please log out and back in to load new settings."
|
||||||
say_cyan "Please log out and log back in to fully apply the Xfce configuration changes."
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user