final fix

This commit is contained in:
[yuri]
2025-11-11 15:38:11 +01:00
parent c2a4df5d1f
commit 62e1040b4d

View File

@@ -124,60 +124,90 @@ if [[ "${DE}" == "xfce" || "${DDE}" == "xfce" ]]; then
fi fi
say_green "XFCE defeault terminal set to alacritty!" say_green "XFCE defeault terminal set to alacritty!"
fi fi
fi
# Set basic configuration ###############################################
SOURCE_DIR="$SCRIPT_DIR/config-files/debian" # Copy settings to HOME
DEST_DIR="$HOME" ###############################################
SOURCE_DIR="$SCRIPT_DIR/config-files/debian"
DEST_DIR="$HOME"
AUTOSTART_DIR="$HOME/.config/autostart"
XFCE_SESSION_DIR="$HOME/.cache/sessions"
# Check source directory # 1. Verify 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
# Detect if XFCE is running # 2. Detect running XFCE session
XFCE_WAS_RUNNING=0 if pgrep -x "xfce4-panel" >/dev/null || pgrep -x "xfconfd" >/dev/null; then
if pgrep -x "xfce4-panel" >/dev/null || pgrep -x "xfconfd" >/dev/null; then say_yellow "XFCE session is currently active."
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 # Check if we're on a Debian-based system
say_yellow "Removing old Xfce session cache..." if grep -qiE "debian|ubuntu|mint" /etc/os-release; then
rm -rf "$HOME/.cache/sessions" say_yellow "Detected Debian-based system. Deferring configuration to next login."
# Copy configs (including hidden) mkdir -p "$AUTOSTART_DIR"
say_yellow "Copying configuration files..." 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 shopt -s dotglob
cp -vrf "$SOURCE_DIR"/* "$DEST_DIR"/ cp -vrf "$SOURCE_DIR"/* "$DEST_DIR"/
shopt -u dotglob 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
# Ensure ownership say_green "Created one-time autostart task:"
chown -R "$(id -u):$(id -g)" "$DEST_DIR/.config/xfce4" say_gray " $AUTOSTART_FILE"
say_cyan "Log out and back in to apply the new XFCE configuration."
say_green "Configuration files copied." exit 0
# 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 else
say_cyan "XFCE was not running. Please log out and back in to load new settings." say_cyan "Non-Debian system detected — applying configuration live."
fi fi
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 # End of script
say_green "Full setup completed." say_green "Full setup completed."