#!/bin/bash
# ============================================================
# butter.sh — Butter Btrfs snapshot GUI
# ============================================================
# Installs Butter, a graphical front-end for managing Btrfs
# snapshots (create, browse, restore, schedule).  It provides
# a user-friendly alternative to running btrfs subvolume
# commands by hand.
#
# btrfs-progs is the essential userspace toolkit needed by
# every tool that manages Btrfs filesystems; it is installed
# from the official repos first because it is a hard dependency.
# Butter itself is AUR-only.
#
# This is an optional module because it is only useful on
# systems whose root (or data) filesystem is Btrfs.
# ============================================================

set -euo pipefail
# Load shared logging helpers from the dotfiles lib
source "$(dirname "${BASH_SOURCE[0]}")/../../lib/logging.sh"

# ── btrfs-progs ───────────────────────────────────────────────────────────────
# btrfs-progs: the official Btrfs userspace tools (mkfs.btrfs, btrfs subvolume,
# btrfs send/receive, etc.).  Required at runtime by Butter and useful on its
# own for CLI snapshot management.
log "Installing btrfs-progs..."
sudo pacman -S --noconfirm --needed btrfs-progs

# ── Butter (AUR) ─────────────────────────────────────────────────────────────
# --answerdiff None : skip the "show diff?" prompt during AUR builds
# --answerclean All : answer "clean" to the "clean build dir?" prompt
# --noconfirm       : suppress all remaining yay/makepkg confirmation prompts
log "Installing butter (AUR)..."
yay -S --answerdiff None --answerclean All --noconfirm butter

log "butter installed."
