# Maintainer: Joey Yakimowich-Payne <jyapayne@pm.me>
#
# BlueRune, from the newest commit of its repository. Build it from this directory with
# `makepkg -si`; docs/install.md says what to do after installing. The release package,
# built from a tagged version and published to the BlueRune package repository, is
# bluerune/PKGBUILD; both install what package-files.sh lists.

pkgname=bluerune-git
_pkgname=bluerune
pkgver=0.0.1.r0.g0000000
pkgrel=1
pkgdesc='Fast, animated desktop shell for Hyprland: bar, launcher, notifications, overview, Settings, and a calculator, image viewer and system monitor'
arch=('x86_64' 'aarch64')
url='https://git.joeypayne.com/jyapayne/bluerune'
license=('Apache-2.0 OR MIT')
depends=(
  # The compositor it is a shell for, and the programs it configures rather than replaces.
  'hyprland>=0.57'
  'hypridle'
  'hyprlock'
  # The BlueRune session: uwsm starts Hyprland and binds the session's services to it.
  'uwsm'
  # Portals (dist/portals/bluerune-portals.conf): sharing and screenshots from Hyprland's,
  # the file chooser and the light or dark preference apps follow from GTK's.
  'xdg-desktop-portal'
  'xdg-desktop-portal-hyprland'
  'xdg-desktop-portal-gtk'
  # Services the bar, quick settings and Settings read and change.
  'power-profiles-daemon'
  'networkmanager'
  'bluez'
  'upower'
  'accountsservice'
  'udisks2'
  'polkit'
  'dbus'
  'systemd'
  # Sound: `wpctl` and `pactl` against PipeWire. `pw-dump` and `pw-cli`: which app a screen
  # is shared with, and stopping it from the bar.
  'pipewire'
  'pipewire-pulse'
  'wireplumber'
  'libpulse'
  # Copying to the clipboard, the screen's brightness, theme archives, GTK settings.
  'wl-clipboard'
  'brightnessctl'
  'libarchive'
  'glib2'
  # bluerune-setup compares each file it would change with what is there, and shows how.
  'diffutils'
  # The fonts every app is given (Settings > Fonts): Inter for the interface (BlueRune's own
  # text has it built in; other apps need it installed), JetBrains Mono Nerd Font for code
  # and terminals, and the Nerd Font symbols after either.
  'inter-font'
  'ttf-jetbrains-mono-nerd'
  'ttf-nerd-fonts-symbols'
  # The shell's own symbols (Material Symbols Rounded).
  'ttf-material-symbols-variable'
  # What the binaries link to.
  'glibc'
  'libgcc'
  'libxkbcommon'
  'vulkan-icd-loader'
  'wayland'
)
makedepends=('cargo' 'git')
# The helper's tests run its libinput Lua plugins under Lua 5.4.
checkdepends=('lua54')
optdepends=(
  'cliphist: clipboard history in the launcher'
  'wtype: type a picked emoji into the window (emoji.type)'
  "hyprpolkitagent: password prompts for apps when BlueRune's own agent (Settings > Lock and privacy > Password prompts for apps) is off"
  'sddm: the BlueRune login screen theme'
  "greetd: BlueRune's own login screen (bluerune-greeter), chosen on Settings > Login screen"
  "xdg-desktop-portal-kde: Dolphin's file chooser in apps, instead of GTK's"
  'grim: screenshots through the portal (apps that ask to take one)'
  'tesseract: copy text out of a screen region'
  'tesseract-data-eng: English for text recognition'
  'wf-recorder: record the screen or a region'
  'satty: edit a screenshot'
  'swappy: edit a screenshot'
  'ddcutil: brightness of external monitors'
  'fcitx5: input methods'
  'orca: screen reader'
  'cups: the Printers page'
  'firewalld: the Firewall page'
  'bolt: the Thunderbolt page'
  'colord: colour profiles of displays'
  'fprintd: fingerprint sign-in'
  'bluez-obex: send and receive files over Bluetooth'
  'wayvnc: the Remote desktop page'
  'gnome-online-accounts: the Online accounts page'
  'modemmanager: mobile broadband'
  'fwupd: firmware updates'
  'pacman-contrib: count updates without touching the system database (checkupdates)'
  'flatpak: Flatpak apps and their permissions'
  'libcanberra: event sounds'
  'xorg-xrdb: font DPI for X11 apps'
  'rsync: the backups on the Storage page'
  'gphoto2: cameras on the Storage page'
)
provides=("$_pkgname")
conflicts=("$_pkgname")
install=bluerune.install
backup=('etc/pam.d/bluerune')
source=("$_pkgname::git+$url.git")
sha256sums=('SKIP')

pkgver() {
  cd "$_pkgname"
  local version
  version=$(sed -n '/^\[workspace\.package\]/,/^\[/s/^version = "\(.*\)"/\1/p' Cargo.toml)
  printf '%s.r%s.g%s' "$version" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)"
}

prepare() {
  cd "$_pkgname"
  export RUSTUP_TOOLCHAIN=stable
  cargo fetch --locked --target "$(rustc --print host-tuple)"
}

build() {
  cd "$_pkgname"
  export RUSTUP_TOOLCHAIN=stable
  export CARGO_TARGET_DIR=target
  cargo build --frozen --release --workspace --bins
}

check() {
  cd "$_pkgname"
  export RUSTUP_TOOLCHAIN=stable
  export CARGO_TARGET_DIR=target
  # The crates with no display or session to need: the shell's state, theme and settings
  # model, and the privileged helper.
  cargo test --frozen --release -p bluerune-core -p bluerune-helper
}

package() {
  cd "$_pkgname"
  bash dist/arch/package-files.sh "$pkgdir" "$pkgname"
}
