fix colors
This commit is contained in:
@@ -1,18 +1,28 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
# Color helpers, logging, variables identical to plasma/xfce scripts
|
||||
##########################
|
||||
# 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"
|
||||
|
||||
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=''
|
||||
# Disable colors if output is not a terminal
|
||||
if [ ! -t 1 ]; then
|
||||
RED="" GREEN="" YELLOW="" CYAN="" GRAY="" BOLD="" RESET=""
|
||||
fi
|
||||
|
||||
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"; }
|
||||
say_red() { printf "%b%s%b\n" "$RED" "$*" "$RESET"; }
|
||||
say_green() { printf "%b%s%b\n" "$GREEN" "$*" "$RESET"; }
|
||||
say_yellow() { printf "%b%s%b\n" "$YELLOW" "$*" "$RESET"; }
|
||||
say_cyan() { printf "%b%s%b\n" "$CYAN" "$*" "$RESET"; }
|
||||
say_gray() { printf "%b%s%b\n" "$GRAY" "$*" "$RESET"; }
|
||||
say_bold() { printf "%b%s%b\n" "$BOLD" "$*" "$RESET"; }
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
OS="${DETECTED_OS:-debian}"
|
||||
@@ -30,26 +40,26 @@ detect_de() { command -v gnome-session >/dev/null 2>&1 && echo "gnome" || 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; }
|
||||
|
||||
color_yellow; echo "Starting Gnome installation..."; color_reset
|
||||
say_yellow "Starting Gnome installation..."
|
||||
|
||||
CURRENT_DE="$(detect_de)"
|
||||
CURRENT_DM="$(detect_display_manager)"
|
||||
|
||||
if [[ -z "$CURRENT_DE" ]]; then
|
||||
color_cyan; echo "No DE detected. Installing Gnome with SDDM..."; color_reset
|
||||
say_cyan "No DE detected. Installing Gnome with SDDM..."
|
||||
install_packages sddm gnome-shell gnome-terminal nautilus gnome-control-center gnome-system-monitor gnome-tweaks network-manager-gnome gnome-keyring gnome-session
|
||||
enable_graphical_target
|
||||
color_green; echo "Gnome with SDDM installed successfully."; color_reset
|
||||
say_green "Gnome with SDDM installed successfully."
|
||||
else
|
||||
color_cyan; echo "Detected existing DE: $CURRENT_DE"; color_reset
|
||||
say_cyan "Detected existing DE: $CURRENT_DE"
|
||||
if [[ "$CURRENT_DM" == "lightdm" ]]; then
|
||||
color_yellow; echo "Replacing LightDM with SDDM..."; color_reset
|
||||
say_yellow "Replacing LightDM with SDDM..."
|
||||
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
|
||||
say_green "LightDM replaced with SDDM."
|
||||
else
|
||||
color_cyan; echo "Current DM: ${CURRENT_DM:-none}, leaving unchanged."; color_reset
|
||||
say_cyan "Current DM: ${CURRENT_DM:-none}, leaving unchanged."
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user