final fix
This commit is contained in:
@@ -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
|
###############################################
|
||||||
|
# Copy settings to HOME
|
||||||
|
###############################################
|
||||||
SOURCE_DIR="$SCRIPT_DIR/config-files/debian"
|
SOURCE_DIR="$SCRIPT_DIR/config-files/debian"
|
||||||
DEST_DIR="$HOME"
|
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
|
||||||
XFCE_WAS_RUNNING=1
|
say_yellow "XFCE session is currently active."
|
||||||
say_yellow "Stopping all XFCE components..."
|
|
||||||
pkill -x xfce4-panel
|
# Check if we're on a Debian-based system
|
||||||
pkill -x xfconfd
|
if grep -qiE "debian|ubuntu|mint" /etc/os-release; then
|
||||||
pkill -x xfwm4
|
say_yellow "Detected Debian-based system. Deferring configuration to next login."
|
||||||
pkill -x xfsettingsd
|
|
||||||
pkill -x xfce4-session
|
mkdir -p "$AUTOSTART_DIR"
|
||||||
sleep 1
|
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
|
fi
|
||||||
|
|
||||||
# Clean cache before copying
|
# 3. Stop XFCE components (only for non-Debian)
|
||||||
say_yellow "Removing old Xfce session cache..."
|
say_yellow "Stopping XFCE daemons if running..."
|
||||||
rm -rf "$HOME/.cache/sessions"
|
pkill -x xfce4-panel || true
|
||||||
|
pkill -x xfconfd || true
|
||||||
|
pkill -x xfwm4 || true
|
||||||
|
sleep 1
|
||||||
|
|
||||||
# Copy configs (including hidden)
|
# 4. Copy configuration files
|
||||||
say_yellow "Copying configuration files..."
|
say_yellow "Copying all configuration files from $SOURCE_DIR to $DEST_DIR ..."
|
||||||
shopt -s dotglob
|
shopt -s dotglob
|
||||||
cp -vrf "$SOURCE_DIR"/* "$DEST_DIR"/
|
cp -vrf "$SOURCE_DIR"/* "$DEST_DIR"/
|
||||||
shopt -u dotglob
|
shopt -u dotglob
|
||||||
|
|
||||||
# Ensure ownership
|
# 5. Clear old XFCE session cache
|
||||||
chown -R "$(id -u):$(id -g)" "$DEST_DIR/.config/xfce4"
|
say_yellow "Clearing XFCE session cache..."
|
||||||
|
rm -rf "$XFCE_SESSION_DIR"
|
||||||
|
|
||||||
say_green "Configuration files copied."
|
# 6. Restart XFCE components (if applicable)
|
||||||
|
if pgrep -x "xfce4-session" >/dev/null; then
|
||||||
# Restart Xfce components only if it was running before
|
say_cyan "Restarting XFCE environment components..."
|
||||||
if [ "$XFCE_WAS_RUNNING" -eq 1 ]; then
|
nohup xfconfd &>/dev/null &
|
||||||
say_bold "Restarting Xfce to apply new configuration..."
|
nohup xfwm4 --replace &>/dev/null &
|
||||||
nohup xfconfd &
|
nohup xfce4-panel &>/dev/null &
|
||||||
nohup xfwm4 --replace &
|
|
||||||
nohup xfce4-panel &
|
|
||||||
nohup xfsettingsd &
|
|
||||||
disown
|
disown
|
||||||
say_green "XFCE configuration applied successfully."
|
say_green "XFCE configuration reloaded successfully."
|
||||||
else
|
else
|
||||||
say_cyan "XFCE was not running. Please log out and back in to load new settings."
|
say_cyan "XFCE was not running. Configuration will load on next login."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
# End of script
|
# End of script
|
||||||
say_green "Full setup completed."
|
say_green "Full setup completed."
|
||||||
|
|||||||
Reference in New Issue
Block a user