# Maintainer: David Young <david@federated.computer>

pkgname=gnome-shell-extension-coredesktop
_uuid=coredesktop@federated.computer
_repo=coredesktop-extension
pkgver=1.0.r0.g0000000
pkgrel=1
pkgdesc="Top bar menu for CoreDesktop's update, refresh, configure and version commands"
arch=(any)
url="https://gitea.federated.computer/Federated_Computer/$_repo"
license=(MIT)
depends=(
  gnome-shell
  systemd
)
makedepends=(git)
source=("git+$url.git")
b2sums=('SKIP')

# metadata.json's version-name plus the commit count and hash, so every commit
# upgrades the package
pkgver() {
  cd $_repo
  local version
  version=$(sed -n 's/^ *"version-name": "\(.*\)",\?$/\1/p' $_uuid/metadata.json)
  printf "%s.r%s.g%s" "$version" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

package() {
  cd $_repo/$_uuid
  local dest="$pkgdir/usr/share/gnome-shell/extensions/$_uuid"

  install -Dm644 -t "$dest" metadata.json extension.js prefs.js stylesheet.css
  install -Dm644 -t "$dest/lib" lib/*.js
  install -Dm644 -t "$dest/icons" icons/*.svg
  install -Dm755 -t "$dest/bin" bin/run-tracked

  # Into the system schema dir, where glib2's pacman hook compiles it. Without
  # a schemas/gschemas.compiled of its own, the extension's getSettings() looks
  # there.
  install -Dm644 -t "$pkgdir/usr/share/glib-2.0/schemas" \
    schemas/org.gnome.shell.extensions.coredesktop.gschema.xml
}
