# Maintainer: Felitendo
# This PKGBUILD is updated automatically:
# https://git.felo.gg/Felitendo/PKGBUILDS

pkgname=untix
pkgver=5.0.0
pkgrel=1
pkgdesc="GTK4 + LibAdwaita client for WebUntis"
arch=('any')
url="https://codeberg.org/ostfriese4/untix"
license=('GPL-3.0-or-later')
# 5.0.0 adds a QR code login: the camera comes through the portal (libportal)
# as a PipeWire stream, is shown with gtk4paintablesink and decoded with
# zxing-cpp's Python binding.
depends=('gtk4' 'libadwaita' 'webkitgtk-6.0' 'libsecret' 'python'
         'python-gobject' 'python-cairo' 'python-requests' 'python-pyotp'
         'python-pillow' 'python-zxing-cpp' 'libportal' 'gstreamer'
         'gst-plugins-base' 'gst-plugin-pipewire' 'gst-plugin-gtk4' 'glib2'
         'hicolor-icon-theme')
makedepends=('meson' 'ninja' 'glib2-devel' 'gettext')
# called untis and timetable on the AUR before; same files
conflicts=('untis' 'timetable')
source=("${pkgname}-${pkgver}.tar.gz::${url}/archive/v${pkgver}.tar.gz")
sha256sums=('05489062e69ecbca1da74a41c46adf7e83a4437897da86822d63fc05020d0c03')

prepare() {
  # The About dialog reads the version from src/api.py, and upstream does not
  # always update it for a release (v4.3.2 still says 4.3.1).
  sed -i "s/^version = \"[^\"]*\"/version = \"$pkgver\"/" untix/src/api.py
}

build() {
  meson setup build untix \
    --prefix=/usr \
    --buildtype=release \
    --wrap-mode=nodownload
  meson compile -C build
}

package() {
  meson install -C build --destdir "$pkgdir"

  # generated by pacman hooks; shipping them would cause file conflicts
  rm -f "$pkgdir/usr/share/glib-2.0/schemas/gschemas.compiled" \
        "$pkgdir/usr/share/applications/mimeinfo.cache" \
        "$pkgdir/usr/share/icons/hicolor/icon-theme.cache"
}
