bugfix
This commit is contained in:
@@ -132,8 +132,10 @@ fi
|
|||||||
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"
|
AUTOSTART_DIR="$HOME/.config/autostart"
|
||||||
|
AUTOSTART_FILE="$AUTOSTART_DIR/xfce-config-apply.desktop"
|
||||||
HELPER_DIR="$HOME/.local/share/xfce-config-apply"
|
HELPER_DIR="$HOME/.local/share/xfce-config-apply"
|
||||||
XFCE_SESSION_DIR="$HOME/.cache/sessions"
|
|
||||||
|
mkdir -p "$AUTOSTART_DIR" "$HOME/.local/bin"
|
||||||
|
|
||||||
# 1. Verify source directory exists
|
# 1. Verify source directory exists
|
||||||
if [ ! -d "$SOURCE_DIR" ]; then
|
if [ ! -d "$SOURCE_DIR" ]; then
|
||||||
@@ -141,82 +143,54 @@ if [ ! -d "$SOURCE_DIR" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 2. Detect running XFCE session
|
# 2. Create helper script
|
||||||
if pgrep -x "xfce4-panel" >/dev/null || pgrep -x "xfconfd" >/dev/null; then
|
cat > "$HELPER_SCRIPT" <<'EOF'
|
||||||
say_yellow "XFCE session is currently active."
|
|
||||||
|
|
||||||
# Debian-based detection
|
|
||||||
if grep -qiE "debian|ubuntu|mint" /etc/os-release; then
|
|
||||||
say_yellow "Detected Debian-based system. Scheduling configuration for next login."
|
|
||||||
|
|
||||||
mkdir -p "$AUTOSTART_DIR" "$HELPER_DIR"
|
|
||||||
AUTOSTART_FILE="$AUTOSTART_DIR/xfce-config-apply.desktop"
|
|
||||||
HELPER_SCRIPT="$HELPER_DIR/run-once.sh"
|
|
||||||
|
|
||||||
# --- Create helper script ---
|
|
||||||
cat > "$HELPER_SCRIPT" <<EOF
|
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
RED="\033[0;31m"; GREEN="\033[0;32m"; YELLOW="\033[0;33m"; CYAN="\033[0;36m"; RESET="\033[0m"
|
||||||
|
say() { printf "%b%s%b\n" "$CYAN" "$*" "$RESET"; }
|
||||||
|
|
||||||
|
SOURCE_DIR="$HOME/config-files/debian"
|
||||||
|
DEST_DIR="$HOME"
|
||||||
|
|
||||||
|
if [ ! -d "\$SOURCE_DIR" ]; then
|
||||||
|
say "Source directory \$SOURCE_DIR not found; skipping."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
say "Applying XFCE configuration early in session..."
|
||||||
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"
|
say "Clearing session cache..."
|
||||||
rm -rf "$HELPER_DIR"
|
rm -rf "\$HOME/.cache/sessions/"
|
||||||
echo "XFCE configuration applied and helper removed."
|
|
||||||
|
say "Configuration applied. Removing one-time autostart entry..."
|
||||||
|
rm -f "\$HOME/.config/autostart/xfce-config-apply.desktop"
|
||||||
|
exit 0
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chmod +x "$HELPER_SCRIPT"
|
chmod +x "$HELPER_SCRIPT"
|
||||||
|
|
||||||
# --- Create autostart file ---
|
# 3. Create autostart entry (early-phase)
|
||||||
cat > "$AUTOSTART_FILE" <<EOF
|
cat > "$AUTOSTART_FILE" <<EOF
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Type=Application
|
Type=Application
|
||||||
Name=Apply XFCE Config
|
Name=Apply XFCE Config (Early)
|
||||||
Comment=One-time XFCE configuration importer
|
Comment=One-time XFCE configuration importer
|
||||||
Exec=$HELPER_SCRIPT
|
Exec=$HELPER_SCRIPT
|
||||||
OnlyShowIn=XFCE;
|
OnlyShowIn=XFCE;
|
||||||
X-GNOME-Autostart-enabled=true
|
X-GNOME-Autostart-enabled=true
|
||||||
|
X-XFCE-Autostart-Phase=Initialization
|
||||||
Hidden=false
|
Hidden=false
|
||||||
NoDisplay=false
|
NoDisplay=false
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
say_green "Created one-time autostart helper:"
|
say_yellow "XFCE configuration will be applied at next login."
|
||||||
say_gray " $AUTOSTART_FILE"
|
say_cyan "Autostart created at: $AUTOSTART_FILE"
|
||||||
say_cyan "→ Log out and back in to apply your new XFCE configuration."
|
say_cyan "Helper script: $HELPER_SCRIPT"
|
||||||
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
|
# End of script
|
||||||
|
|||||||
Reference in New Issue
Block a user