# Maintainer: Jatin K Malik <jatinkrmalik@gmail.com>
# Updated by .github/workflows/release.yml on v* tags. Setup: docs/AUR.md

pkgname=vocalinux
# AUR pkgver cannot contain hyphens (v0.14.0-beta -> 0.14.0beta).
pkgver=0.17.0
_tag=0.17.0
pkgrel=1
pkgdesc="Free, offline voice dictation for Linux"
arch=('any')
url="https://github.com/VocaHQ/vocalinux"
license=('AGPL-3.0-only')
depends=(
  'python>=3.11'
  'python-gobject'
  'gtk3'
  'libayatana-appindicator'
  'ibus'
  'gobject-introspection'
  'python-cairo'
  'python-pynput'
  'python-pywhispercpp'
  'python-pyaudio'
  'portaudio'
  'python-numpy'
  'python-requests'
  'python-tqdm'
  'python-psutil'
  'python-evdev'
  'python-xlib'
  'hicolor-icon-theme'
)
# --no-isolation uses distro python-setuptools (Arch extra is 84+).
# pyproject.toml build-system.requires must accept that version.
makedepends=(
  'python-build'
  'python-installer'
  'python-wheel'
  'python-setuptools'
)
optdepends=(
  'python-pywhispercpp-cpu: CPU-only whisper.cpp backend (default provider)'
  'python-pywhispercpp-cuda: NVIDIA GPU whisper.cpp backend'
  'python-pywhispercpp-rocm: AMD GPU whisper.cpp backend'
  'python-onnxruntime: Silero VAD'
  # One line per selectable engine. Without it the engine is offered in
  # Settings and fails at import, which is how vosk and whisper shipped too.
  'python-vosk: Vosk engine'
  'python-openai-whisper: OpenAI Whisper engine'
  'python-sherpa-onnx: Parakeet TDT 0.6B engine'
  'python-faster-whisper: faster-whisper engine'
  'xdotool: X11 injection fallback'
  'xclip: X11 clipboard tools (copy/paste injection fallbacks)'
  'wl-clipboard: Wayland clipboard (wl-copy/wl-paste) injection fallbacks'
  'wtype: Wayland keystroke injection fallback'
)
conflicts=('vocalinux-git')
source=("${pkgname}-${_tag}.tar.gz::https://github.com/VocaHQ/vocalinux/archive/refs/tags/v${_tag}.tar.gz")
# SKIP until the v${_tag} tarball exists. release.yml sets updpkgsums=true on publish.
sha256sums=('SKIP')

build() {
  cd "${pkgname}-${_tag}"
  python -m build --wheel --no-isolation
}

package() {
  cd "${pkgname}-${_tag}"
  python -m installer --destdir="${pkgdir}" dist/*.whl

  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  install -Dm644 vocalinux.desktop "${pkgdir}/usr/share/applications/vocalinux.desktop"

  for icon in resources/icons/scalable/*.svg; do
    install -Dm644 "$icon" "${pkgdir}/usr/share/icons/hicolor/scalable/apps/$(basename "$icon")"
  done
}
