Dotfiles/setup/modules/optional-Modules/apps/lightdm.sh

72 lines
3.5 KiB
Bash
Executable File

#!/bin/bash
# lightdm.sh — LightDM + GTK greeter (cyberqueer-themed)
#
# The default greeter for HyprLua. LightDM's GTK greeter reuses the cyberqueer
# GTK theme shipped in this repo (gtk-themes/cyberqueer), so it matches the rest
# of the desktop, and it is driven by a single trivial INI file
# (/etc/lightdm/lightdm-gtk-greeter.conf) — the simplest config of the
# LightDM/LXDM/GDM options.
#
# This module is self-contained (installs the theme + skull background itself)
# so it can also be selected on its own from modules.conf. It is mutually
# exclusive with the ly greeter module. Enabling LightDM here disables the other
# greeters (greetd, ly) and the tty1 getty so exactly one display manager runs.
set -euo pipefail
source "$(dirname "${BASH_SOURCE[0]}")/../../lib/logging.sh"
# apps/ → optional-Modules → modules → setup → repo root (four levels up).
DOTFILES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../../.." && pwd)"
log "Installing LightDM + GTK greeter..."
sudo pacman -S --noconfirm --needed lightdm lightdm-gtk-greeter
# ── Ensure the cyberqueer GTK theme is present system-wide ────────────────────
# The greeter runs as the 'lightdm' user and reads themes from /usr/share/themes.
# DE modules already install this, but copy it here too so LightDM can be chosen
# standalone. (Papirus-Dark icons are pulled in by the desktop modules.)
GTK_THEME_SRC="$DOTFILES_DIR/gtk-themes/cyberqueer"
if [[ -d "$GTK_THEME_SRC" ]]; then
log "Installing cyberqueer GTK theme to /usr/share/themes..."
sudo cp -r "$GTK_THEME_SRC" /usr/share/themes/
else
warn "cyberqueer GTK theme not found at $GTK_THEME_SRC — greeter will use the default GTK theme."
fi
# ── Render the skull background from the bundled SVG ───────────────────────────
# lightdm-gtk-greeter needs a raster background; convert the 1920x1080 SVG.
SKULL_SRC="$DOTFILES_DIR/resources/bg-skull.svg"
SKULL_DST="/usr/share/backgrounds/cyberqueer-skull.png"
if [[ -f "$SKULL_SRC" ]]; then
if ! command -v rsvg-convert &>/dev/null; then
log "Installing librsvg (rsvg-convert) for SVG→PNG conversion..."
sudo pacman -S --noconfirm --needed librsvg
fi
log "Rendering skull background → $SKULL_DST..."
TMP_BG="$(mktemp /tmp/lightdm-skull.XXXXXX.png)"
trap 'rm -f "$TMP_BG"' EXIT
rsvg-convert -w 1920 "$SKULL_SRC" -o "$TMP_BG"
sudo install -Dm644 "$TMP_BG" "$SKULL_DST"
else
warn "Skull SVG not found at $SKULL_SRC — greeter will fall back to a solid background."
fi
# ── Deploy the greeter configuration ──────────────────────────────────────────
GREETER_CONF_SRC="$DOTFILES_DIR/etc-lightdm/lightdm-gtk-greeter.conf"
if [[ -f "$GREETER_CONF_SRC" ]]; then
log "Deploying lightdm-gtk-greeter.conf..."
sudo install -Dm644 "$GREETER_CONF_SRC" /etc/lightdm/lightdm-gtk-greeter.conf
else
warn "Greeter config not found at $GREETER_CONF_SRC — LightDM will use greeter defaults."
fi
# ── Make LightDM the sole display manager ─────────────────────────────────────
# LightDM manages its own VT; free tty1 and disable the competing greeters so
# nothing else races it.
sudo systemctl disable getty@tty1.service || true
disable_service greetd.service
disable_service ly@tty1.service
enable_service lightdm.service
log "LightDM installed and enabled. The cyberqueer GTK greeter starts on next boot."