#!/bin/bash
# ============================================================
# ardour.sh — Ardour digital audio workstation (DAW)
# ============================================================
# Installs Ardour, a professional-grade open-source DAW for
# recording, editing, and mixing multi-track audio and MIDI.
# It is distributed as a Flatpak here to get the upstream-
# sanctioned build with all codec/plugin support enabled, and
# to isolate it from system audio libraries that may differ
# across Arch versions.  It is an optional module because most
# users do not need a full DAW; lighter options like Audacity
# or LMMS are separate modules.
# ============================================================

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

log "Installing Ardour (Flatpak)..."

# ensure_flatpak: verifies that flatpak and the Flathub remote are set up;
# defined in lib/logging.sh (or a sourced helper).  Idempotent.
ensure_flatpak

# Install Ardour from the Flathub repository.
# -y skips the interactive confirmation prompt so the script is non-interactive.
sudo flatpak install --system -y flathub org.ardour.Ardour

# apply_flatpak_theme: applies the cyberqueer GTK theme override so Ardour's
# GTK widgets match the rest of the desktop, rather than using the Flatpak
# default Adwaita theme.
apply_flatpak_theme "org.ardour.Ardour"

log "Ardour installed."
