#!/bin/bash
# set -euo pipefail: abort on errors, unset vars, and pipeline failures.
set -euo pipefail
source "$(dirname "${BASH_SOURCE[0]}")/../lib/logging.sh"

# plasma-meta: meta-package that pulls in the full Plasma desktop environment.
# sddm: Simple Desktop Display Manager (KDE's preferred login screen).
# sddm-kcm: KCM (KDE Control Module) for configuring SDDM inside System Settings.
# xdg-desktop-portal-kde: portal backend for Flatpak/Wayland screen-share,
#   file-chooser, and print dialogs inside the KDE environment.
# konsole dolphin kate gwenview ark spectacle okular elisa: core KDE apps
#   (terminal, file manager, editor, image viewer, archiver, screenshots, PDF, music).
# plasma-browser-integration: browser extension that exposes tabs to KDE.
# bluedevil: KDE's Bluetooth manager GUI (sits on top of bluez).
# power-profiles-daemon: exposes power-profile switching (balanced/performance/powersave)
#   to KDE's Power Management settings.
log "Installing KDE Plasma desktop..."
sudo pacman -S --noconfirm --needed \
    plasma-meta \
    sddm sddm-kcm \
    xdg-desktop-portal-kde \
    konsole dolphin kate gwenview ark spectacle okular elisa \
    plasma-browser-integration \
    pipewire wireplumber pipewire-alsa pipewire-jack pipewire-pulse \
    networkmanager \
    bluez bluez-utils bluedevil \
    power-profiles-daemon \
    flatpak

log "Enabling services..."
# sddm provides the graphical login screen; must be enabled before rebooting.
sudo systemctl enable sddm.service
sudo systemctl enable NetworkManager.service
sudo systemctl enable bluetooth.service

log "KDE Plasma installation complete. Reboot to start."
