final fix
This commit is contained in:
@@ -124,60 +124,90 @@ if [[ "${DE}" == "xfce" || "${DDE}" == "xfce" ]]; then
|
||||
fi
|
||||
say_green "XFCE defeault terminal set to alacritty!"
|
||||
fi
|
||||
|
||||
# Set basic configuration
|
||||
SOURCE_DIR="$SCRIPT_DIR/config-files/debian"
|
||||
DEST_DIR="$HOME"
|
||||
|
||||
# Check source directory
|
||||
if [ ! -d "$SOURCE_DIR" ]; then
|
||||
say_red "Error: Source directory '$SOURCE_DIR' not found. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 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 all XFCE components..."
|
||||
pkill -x xfce4-panel
|
||||
pkill -x xfconfd
|
||||
pkill -x xfwm4
|
||||
pkill -x xfsettingsd
|
||||
pkill -x xfce4-session
|
||||
sleep 1
|
||||
fi
|
||||
|
||||
# Clean cache before copying
|
||||
say_yellow "Removing old Xfce session cache..."
|
||||
rm -rf "$HOME/.cache/sessions"
|
||||
|
||||
# Copy configs (including hidden)
|
||||
say_yellow "Copying configuration files..."
|
||||
shopt -s dotglob
|
||||
cp -vrf "$SOURCE_DIR"/* "$DEST_DIR"/
|
||||
shopt -u dotglob
|
||||
|
||||
# Ensure ownership
|
||||
chown -R "$(id -u):$(id -g)" "$DEST_DIR/.config/xfce4"
|
||||
|
||||
say_green "Configuration files copied."
|
||||
|
||||
# Restart Xfce components only if it was running before
|
||||
if [ "$XFCE_WAS_RUNNING" -eq 1 ]; then
|
||||
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 was not running. Please log out and back in to load new settings."
|
||||
fi
|
||||
|
||||
|
||||
fi
|
||||
|
||||
###############################################
|
||||
# Copy settings to HOME
|
||||
###############################################
|
||||
SOURCE_DIR="$SCRIPT_DIR/config-files/debian"
|
||||
DEST_DIR="$HOME"
|
||||
AUTOSTART_DIR="$HOME/.config/autostart"
|
||||
XFCE_SESSION_DIR="$HOME/.cache/sessions"
|
||||
|
||||
# 1. Verify source directory exists
|
||||
if [ ! -d "$SOURCE_DIR" ]; then
|
||||
say_red "Error: Source directory '$SOURCE_DIR' not found. Aborting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 2. Detect running XFCE session
|
||||
if pgrep -x "xfce4-panel" >/dev/null || pgrep -x "xfconfd" >/dev/null; then
|
||||
say_yellow "XFCE session is currently active."
|
||||
|
||||
# Check if we're on a Debian-based system
|
||||
if grep -qiE "debian|ubuntu|mint" /etc/os-release; then
|
||||
say_yellow "Detected Debian-based system. Deferring configuration to next login."
|
||||
|
||||
mkdir -p "$AUTOSTART_DIR"
|
||||
AUTOSTART_FILE="$AUTOSTART_DIR/xfce-config-apply.desktop"
|
||||
|
||||
cat > "$AUTOSTART_FILE" <<EOF
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Apply XFCE Config
|
||||
Comment=One-time XFCE configuration importer
|
||||
Exec=bash -c '
|
||||
shopt -s dotglob
|
||||
cp -vrf "$SOURCE_DIR"/* "$DEST_DIR"/
|
||||
shopt -u dotglob
|
||||
rm -rf "$XFCE_SESSION_DIR"
|
||||
rm -f "$AUTOSTART_FILE"
|
||||
echo "XFCE config applied on login and autostart entry removed."
|
||||
'
|
||||
OnlyShowIn=XFCE;
|
||||
X-GNOME-Autostart-enabled=true
|
||||
Hidden=false
|
||||
NoDisplay=false
|
||||
EOF
|
||||
|
||||
say_green "Created one-time autostart task:"
|
||||
say_gray " $AUTOSTART_FILE"
|
||||
say_cyan "Log out and back in to apply the new XFCE configuration."
|
||||
exit 0
|
||||
else
|
||||
say_cyan "Non-Debian system detected — applying configuration live."
|
||||
fi
|
||||
fi
|
||||
|
||||
# 3. Stop XFCE components (only for non-Debian)
|
||||
say_yellow "Stopping XFCE daemons if running..."
|
||||
pkill -x xfce4-panel || true
|
||||
pkill -x xfconfd || true
|
||||
pkill -x xfwm4 || true
|
||||
sleep 1
|
||||
|
||||
# 4. Copy configuration files
|
||||
say_yellow "Copying all configuration files from $SOURCE_DIR to $DEST_DIR ..."
|
||||
shopt -s dotglob
|
||||
cp -vrf "$SOURCE_DIR"/* "$DEST_DIR"/
|
||||
shopt -u dotglob
|
||||
|
||||
# 5. Clear old XFCE session cache
|
||||
say_yellow "Clearing XFCE session cache..."
|
||||
rm -rf "$XFCE_SESSION_DIR"
|
||||
|
||||
# 6. Restart XFCE components (if applicable)
|
||||
if pgrep -x "xfce4-session" >/dev/null; then
|
||||
say_cyan "Restarting XFCE environment components..."
|
||||
nohup xfconfd &>/dev/null &
|
||||
nohup xfwm4 --replace &>/dev/null &
|
||||
nohup xfce4-panel &>/dev/null &
|
||||
disown
|
||||
say_green "XFCE configuration reloaded successfully."
|
||||
else
|
||||
say_cyan "XFCE was not running. Configuration will load on next login."
|
||||
fi
|
||||
|
||||
|
||||
# End of script
|
||||
say_green "Full setup completed."
|
||||
|
||||
Reference in New Issue
Block a user