214 lines
7.0 KiB
Bash
Executable File
214 lines
7.0 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
##########################
|
|
# Color helpers (printf-safe, no tput)
|
|
##########################
|
|
RED="\033[0;31m"
|
|
GREEN="\033[0;32m"
|
|
YELLOW="\033[0;33m"
|
|
CYAN="\033[0;36m"
|
|
GRAY="\033[0;37m"
|
|
BOLD="\033[1m"
|
|
RESET="\033[0m"
|
|
|
|
# Disable colors if output is not a terminal
|
|
if [ ! -t 1 ]; then
|
|
RED="" GREEN="" YELLOW="" CYAN="" GRAY="" BOLD="" RESET=""
|
|
fi
|
|
|
|
say_red() { printf "\n"; printf "%b%s%b\n" "$RED" "$*" "$RESET"; }
|
|
say_green() { printf "\n"; printf "%b%s%b\n" "$GREEN" "$*" "$RESET"; }
|
|
say_yellow() { printf "\n"; printf "%b%s%b\n" "$YELLOW" "$*" "$RESET"; }
|
|
say_cyan() { printf "\n"; printf "%b%s%b\n" "$CYAN" "$*" "$RESET"; }
|
|
say_gray() { printf "\n"; printf "%b%s%b\n" "$GRAY" "$*" "$RESET"; }
|
|
say_bold() { printf "\n"; printf "%b%s%b\n" "$BOLD" "$*" "$RESET"; }
|
|
|
|
##########################
|
|
# Use exported variables from main detection script
|
|
##########################
|
|
OS="${DETECTED_OS:-debian}"
|
|
DDE="${DETECTED_DE:-}"
|
|
DE="${SELECTED_DE:-none}"
|
|
TWM="${SELECTED_TWM:-none}"
|
|
INSTALL_LEVEL="${INSTALL_LEVEL:-minimal}"
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
##########################
|
|
# Helper functions
|
|
##########################
|
|
install_packages() { sudo apt update; sudo apt install -y --no-install-recommends "$@"; }
|
|
is_package_installed() { dpkg -s "$1" &>/dev/null; }
|
|
|
|
say_yellow "Starting full setup..."
|
|
|
|
# Run minimal first
|
|
bash "$SCRIPT_DIR/debian-minimal.sh"
|
|
|
|
# Add extra packages
|
|
install_packages arandr catfish galculator network-manager network-manager-applet network-manager-openvpn numlockx pulseaudio pavucontrol playerctl gparted xfce4-indicator-plugin xfce4-pulseaudio-plugin xfce4-clipman-plugin
|
|
|
|
# Ensure NetworkManager manages all interfaces
|
|
echo "Setting NetworkManager to manage all interfaces..."
|
|
sudo cp /etc/network/interfaces /etc/network/interfaces.bak.$(date +%s)
|
|
sudo tee /etc/network/interfaces > /dev/null <<'EOF'
|
|
auto lo
|
|
iface lo inet loopback
|
|
EOF
|
|
sudo sed -i 's/^managed=.*/managed=true/' /etc/NetworkManager/NetworkManager.conf || \
|
|
echo -e "[ifupdown]\nmanaged=true" | sudo tee -a /etc/NetworkManager/NetworkManager.conf
|
|
sudo systemctl restart NetworkManager
|
|
|
|
########################################
|
|
# XFCE-specific configuration
|
|
########################################
|
|
if [[ "${DE}" == "xfce" || "${DDE}" == "xfce" ]]; then
|
|
echo
|
|
say_cyan "Applying XFCE defaults: fonts, browser, and terminal..."
|
|
|
|
# Ensure xfconf-query exists (for XFCE settings)
|
|
if ! command -v xfconf-query >/dev/null 2>&1; then
|
|
say_yellow "xfconf-query not found — installing xfce4-settings..."
|
|
install_packages xfce4-settings
|
|
fi
|
|
|
|
# set fonts
|
|
# Wait for xfconf to be available (only needed if running inside the same session)
|
|
if command -v xfconf-query >/dev/null 2>&1; then
|
|
# Interface font (UI)
|
|
xfconf-query -c xsettings -p /Gtk/FontName -s "RobotoMono Nerd Font Regular 10"
|
|
# Monospace font (terminals, editors)
|
|
xfconf-query -c xsettings -p /Gtk/MonospaceFontName -s "RobotoMono Nerd Font Mono Regular 10"
|
|
|
|
say_green "XFCE fonts updated successfully!"
|
|
else
|
|
say_yellow "xfconf-query not found — skipping XFCE font config (will apply at first login)."
|
|
fi
|
|
|
|
# Set browser default
|
|
if command -v chromium >/dev/null 2>&1; then
|
|
mkdir -p "$HOME/.config/xfce4/"
|
|
HELPERS_FILE="$HOME/.config/xfce4/helpers.rc"
|
|
|
|
# Ensure the helpers file exists
|
|
touch "$HELPERS_FILE"
|
|
|
|
# Update or insert browser entry
|
|
if grep -q '^WebBrowser=' "$HELPERS_FILE"; then
|
|
sed -i 's|^WebBrowser=.*|WebBrowser=chromium|' "$HELPERS_FILE"
|
|
else
|
|
echo "WebBrowser=chromium" >> "$HELPERS_FILE"
|
|
fi
|
|
say_green "XFCE defeault browser set to chromium!"
|
|
fi
|
|
|
|
# Set default terminal
|
|
if command -v alacritty >/dev/null 2>&1; then
|
|
mkdir -p "$HOME/.config/xfce4/"
|
|
HELPERS_FILE="$HOME/.config/xfce4/helpers.rc"
|
|
|
|
touch "$HELPERS_FILE"
|
|
|
|
# TerminalEmulator entry
|
|
if grep -q '^TerminalEmulator=' "$HELPERS_FILE"; then
|
|
sed -i 's|^TerminalEmulator=.*|TerminalEmulator=alacritty|' "$HELPERS_FILE"
|
|
else
|
|
echo "TerminalEmulator=alacritty" >> "$HELPERS_FILE"
|
|
fi
|
|
|
|
# TerminalEmulatorCommand entry
|
|
if grep -q '^TerminalEmulatorCommand=' "$HELPERS_FILE"; then
|
|
sed -i 's|^TerminalEmulatorCommand=.*|TerminalEmulatorCommand=alacritty|' "$HELPERS_FILE"
|
|
else
|
|
echo "TerminalEmulatorCommand=alacritty" >> "$HELPERS_FILE"
|
|
fi
|
|
say_green "XFCE defeault terminal set to alacritty!"
|
|
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."
|