From 382747ba9b00af778ab526953bb7c858f0bb851d Mon Sep 17 00:00:00 2001 From: Pepe44DEV Date: Wed, 27 May 2026 23:23:55 +0200 Subject: [PATCH] fix: theme-Auswahl + SDDM-Theme-Correctness Drei Probleme gefixt: 1. Theme-Auswahl waehrend Install - apply-theme.sh zeigt jetzt alle .theme-Files via tui_choose - Benutzer waehlt interaktiv (gum/whiptail/basic) - Bei nur einem Theme: auto-select 2. SDDM wendet falsches Theme an - sddm.sh erzeugt /var/lib/pascal-sddm-theme/ mit user chown - Liest current-theme.conf + hyprpaper.conf fuer aktuelle Farben - Schreibt theme.conf in /usr/share/sddm/themes/pascal-hypr/ - Config heisst jetzt 90-pascal-hypr.conf (hoehere Priority) - apply-theme.sh erzeugt state dir VOR theme-menu.sh --apply 3. tui_choose basic mode fix - ${!choice} funktioniert nicht fuer numerische Indices - labels+=("$@") + ${labels[$choice]} statt Positional-Params --- lib/tui.sh | 12 +++--- modules/core/sddm.sh | 71 ++++++++++++++++++++++++++++++- modules/post/apply-theme.sh | 83 ++++++++++++++++++++++++++----------- 3 files changed, 133 insertions(+), 33 deletions(-) diff --git a/lib/tui.sh b/lib/tui.sh index 6e59406..46d9cbf 100755 --- a/lib/tui.sh +++ b/lib/tui.sh @@ -71,13 +71,13 @@ tui_choose() { done whiptail --menu "$prompt" 20 60 10 "${items[@]}" 3>&1 1>&2 2>&3 else + local labels=("$@") printf '\n==============================\n' printf ' %s\n' "$(_strip_format "$prompt")" printf '==============================\n' - local i=0 - for item in "$@"; do - printf ' [%d] %s\n' "$i" "$item" - ((i++)) + local i + for i in "${!labels[@]}"; do + printf ' [%d] %s\n' "$i" "${labels[$i]}" done printf ' [x] Cancel\n' printf '==============================\n' @@ -86,8 +86,8 @@ tui_choose() { if [[ "$choice" == "x" ]]; then return 1 fi - if [[ "$choice" =~ ^[0-9]+$ ]] && ((choice < ${#@})); then - printf '%s\n' "${!choice}" + if [[ "$choice" =~ ^[0-9]+$ ]] && ((choice < ${#labels[@]})); then + printf '%s\n' "${labels[$choice]}" fi fi } diff --git a/modules/core/sddm.sh b/modules/core/sddm.sh index b290e63..cceb112 100755 --- a/modules/core/sddm.sh +++ b/modules/core/sddm.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash module_description() { - printf "SDDM Theme - install custom login theme\n" + printf "SDDM Theme - install custom login theme with current colors\n" } module_required() { return 1; } @@ -38,8 +38,75 @@ module_main() { sudo_run cp -a "$sddm_theme_dir/pascal-hypr" /usr/share/sddm/themes/ + sudo_run mkdir -p /var/lib/pascal-sddm-theme + sudo_run chown "$(id -u):$(id -g)" /var/lib/pascal-sddm-theme + + local current_theme_conf="$HOME/.config/hypr/current-theme.conf" + local current_wallpaper="$HOME/.config/hypr/current-wallpaper" + local hyprpaper_conf="$HOME/.config/hypr/hyprpaper.conf" + + local wallpaper="" + local accent="#f38ba8" + local accent2="#cba6f7" + local background="#18141f" + local panel="#313244" + local foreground="#f5e0dc" + local muted="#cdd6f4" + local selected="#11111b" + local theme_name="Pascal Hypr" + + if [[ -f "$current_wallpaper" ]]; then + wallpaper="$(< "$current_wallpaper")" + fi + + if [[ -f "$current_theme_conf" ]]; then + local line + while IFS= read -r line; do + [[ "$line" =~ ^# ]] && continue + [[ "$line" =~ ^[[:space:]]*$ ]] && continue + if [[ "$line" =~ col\.active_border[[:space:]]*=[[:space:]]*(.*) ]]; then + local border="${BASH_REMATCH[1]}" + border="${border#rgba(}" + border="${border%ee)}" + accent="#${border:0:2}${border:2:2}${border:4:2}" + fi + done < "$current_theme_conf" + fi + + if [[ -f "$hyprpaper_conf" ]]; then + if [[ -z "$wallpaper" ]]; then + local wl + wl="$(grep 'path' "$hyprpaper_conf" 2>/dev/null | head -1 | sed 's/.*=[[:space:]]*//' | tr -d ' "')" + [[ -n "$wl" ]] && wallpaper="$wl" + fi + + if [[ "$wallpaper" == /home/pascal/* ]]; then + wallpaper="${wallpaper/#\/home\/pascal/$HOME}" + fi + fi + + if [[ -n "$wallpaper" && -f "$wallpaper" ]]; then + local ext="${wallpaper##*.}" + [[ "$ext" == "$wallpaper" ]] && ext="jpg" + sudo_run cp "$wallpaper" "/var/lib/pascal-sddm-theme/wallpaper.$ext" + fi + + local theme_conf="/usr/share/sddm/themes/pascal-hypr/theme.conf" + sudo_run tee "$theme_conf" >/dev/null </dev/null) - local theme_file="" - if [[ -f "$themes_dir/$default_theme.theme" ]]; then - theme_file="$themes_dir/$default_theme.theme" - elif [[ -f "$themes_dir/forest-neon.theme" ]]; then - theme_file="$themes_dir/forest-neon.theme" - elif [[ -f "$themes_dir/rose-night.theme" ]]; then - theme_file="$themes_dir/rose-night.theme" - else - local available - available="$(find "$themes_dir" -name '*.theme' -type f | head -1)" - if [[ -n "$available" ]]; then - theme_file="$available" - fi - fi - - if [[ -z "$theme_file" ]]; then + if ((${#theme_files[@]} == 0)); then log_warn "No theme files found in $themes_dir" return 1 fi - if tui_confirm "Apply theme: $(basename "$theme_file" .theme).theme?"; then - log_info "Applying theme: $(basename "$theme_file")" - tui_spin "Applying theme..." bash "$theme_script" --apply "$theme_file" + local theme_names=() + local file + for file in "${theme_files[@]}"; do + theme_names+=("$(basename "$file" .theme)") + done - if have notify-send; then - notify-send "Omeron" "Theme applied: $(basename "$theme_file" .theme)" >/dev/null 2>&1 || true + tui_bold "Available themes:" + local i + for i in "${!theme_names[@]}"; do + tui_info "[$i] ${theme_names[$i]}" + done + printf '\n' + + local choice + if ((${#theme_files[@]} == 1)); then + tui_info "Only one theme available, auto-selecting: ${theme_names[0]}" + choice="${theme_files[0]}" + else + choice="$( + local labels=() + for name in "${theme_names[@]}"; do + labels+=("$name") + done + tui_choose "Select a theme" "${labels[@]}" + )" + if [[ -z "$choice" ]]; then + log_info "No theme selected, skipping" + return 0 fi - - log_success "Theme applied: $(basename "$theme_file" .theme)" + local idx + for idx in "${!theme_names[@]}"; do + if [[ "$choice" == "${theme_names[$idx]}" ]]; then + choice="${theme_files[$idx]}" + break + fi + done fi + + if [[ -z "$choice" || ! -f "$choice" ]]; then + log_warn "Invalid theme selection" + return 1 + fi + + log_info "Selected theme: $(basename "$choice" .theme)" + + if ! tui_confirm "Apply theme: $(basename "$choice" .theme)?"; then + log_info "Theme application skipped" + return 0 + fi + + sudo_run mkdir -p /var/lib/pascal-sddm-theme 2>/dev/null || true + sudo_run chown "$(id -u):$(id -g)" /var/lib/pascal-sddm-theme 2>/dev/null || true + + log_info "Applying theme..." + tui_spin "Applying theme..." bash "$theme_script" --apply "$choice" + + log_success "Theme applied: $(basename "$choice" .theme)" }