72 lines
2.6 KiB
Bash
Executable File
72 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
##########################
|
|
# Color helpers
|
|
##########################
|
|
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'
|
|
[ ! -t 1 ] && RED='' GREEN='' YELLOW='' CYAN='' GRAY='' BOLD='' RESET=''
|
|
|
|
color_red() { printf '%b' "$RED"; }
|
|
color_green() { printf '%b' "$GREEN"; }
|
|
color_yellow() { printf '%b' "$YELLOW"; }
|
|
color_cyan() { printf '%b' "$CYAN"; }
|
|
color_gray() { printf '%b' "$GRAY"; }
|
|
color_reset() { printf '%b' "$RESET"; }
|
|
|
|
##########################
|
|
# Logging
|
|
##########################
|
|
LOGFILE="${LOGFILE:-/tmp/debian-plasma.log}"
|
|
exec > >(tee -a "$LOGFILE") 2>&1
|
|
|
|
##########################
|
|
# Variables
|
|
##########################
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
OS="${DETECTED_OS:-debian}"
|
|
DDE="${DETECTED_DE:-}"
|
|
DE="${SELECTED_DE:-none}"
|
|
TWM="${SELECTED_TWM:-none}"
|
|
INSTALL_LEVEL="${INSTALL_LEVEL:-minimal}"
|
|
|
|
##########################
|
|
# Helper functions
|
|
##########################
|
|
install_packages() { sudo apt update; sudo apt install -y --no-install-recommends "$@"; }
|
|
is_package_installed() { dpkg -s "$1" &>/dev/null; }
|
|
detect_de() { command -v startplasma-x11 >/dev/null 2>&1 && echo "plasma" || echo ""; }
|
|
detect_display_manager() { [ -f /etc/X11/default-display-manager ] && basename "$(cat /etc/X11/default-display-manager)" || echo ""; }
|
|
enable_graphical_target() { sudo systemctl enable sddm; sudo systemctl set-default graphical.target; }
|
|
|
|
##########################
|
|
# Install Plasma
|
|
##########################
|
|
color_yellow; echo "Starting KDE Plasma installation..."; color_reset
|
|
|
|
CURRENT_DE="$(detect_de)"
|
|
CURRENT_DM="$(detect_display_manager)"
|
|
|
|
if [[ -z "$CURRENT_DE" ]]; then
|
|
color_cyan; echo "No DE detected. Installing KDE Plasma with SDDM..."; color_reset
|
|
install_packages sddm plasma-desktop dolphin konsole kate plasma-nm plasma-workspace kde-config-gtk-style kde-config-sddm plasma-discover kscreen
|
|
enable_graphical_target
|
|
color_green; echo "KDE Plasma with SDDM installed successfully."; color_reset
|
|
else
|
|
color_cyan; echo "Detected existing DE: $CURRENT_DE"; color_reset
|
|
if [[ "$CURRENT_DM" == "lightdm" ]]; then
|
|
color_yellow; echo "Replacing LightDM with SDDM..."; color_reset
|
|
sudo systemctl disable lightdm
|
|
sudo apt purge -y lightdm lightdm-gtk-greeter
|
|
install_packages sddm
|
|
enable_graphical_target
|
|
color_green; echo "LightDM replaced with SDDM."; color_reset
|
|
else
|
|
color_cyan; echo "Current DM: ${CURRENT_DM:-none}, leaving unchanged."; color_reset
|
|
fi
|
|
fi
|
|
|
|
# Pause
|
|
read -n 1 -s -r -p "Press any key to continue"
|
|
echo |