#!/bin/bash
# ============================================================
# audacity.sh — Audacity audio editor
# ============================================================
# Installs Audacity, a cross-platform, open-source audio editor
# and recorder.  It is useful for quick edits, noise removal,
# format conversion, and podcast production — lighter-weight
# than a full DAW like Ardour.  Flatpak is preferred over the
# AUR package because it bundles all FFmpeg/codec dependencies
# and avoids conflicts with system libraries.
# ============================================================

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 Audacity (Flatpak)..."

# ensure_flatpak: verifies that flatpak and the Flathub remote are present;
# idempotent — safe to call even if Flatpak is already configured.
ensure_flatpak

# Install from Flathub. -y suppresses the interactive confirmation.
sudo flatpak install --system -y flathub org.audacityteam.Audacity

# apply_flatpak_theme: injects the cyberqueer GTK theme into Audacity's
# Flatpak environment so it renders consistently with the rest of the desktop.
apply_flatpak_theme "org.audacityteam.Audacity"

log "Audacity installed."
