# Maintainer: Gavin Luo <lunt.luo@gmail.com>

pkgname=gnome-shell-extension-autohide-battery
pkgver=59
pkgrel=1
pkgdesc="GNOME Shell extension to hide battery icon, if battery is fully charged and AC is connected"
arch=('any')
url="https://github.com/ai/autohide-battery"
license=('MIT')
depends=('gnome-shell>=45')
makedepends=()
_work_dir=autohide-battery-${pkgver}
source=("${_work_dir}".tar.gz::"${url}"/archive/refs/tags/"${pkgver}".tar.gz)
b2sums=('99e2079f78cc5bcf39f931c0e4e1b3cfd7b3eb00e824f64ff66d2645eea947d640401ac381c3ecf72ddb3cbf97939a7028623c48a8a6e32b5a6834b2a2a29041')

build() {
  cd "${_work_dir}"

  make build
}

package() {
  cd "${_work_dir}"

  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

  local _uuid; _uuid=$(grep -Po '(?<="uuid": ")[^"]*' metadata.json)

  local _ext_dir="$pkgdir/usr/share/gnome-shell/extensions/${_uuid}"
  install -d "$_ext_dir"
  bsdtar --uid 0 --gid 0 -xvf "${_uuid}".shell-extension.zip -C "$_ext_dir"

  local _schema_dir="$pkgdir/usr/share/glib-2.0"
  install -d "$_schema_dir"
  mv "$pkgdir/usr/share/gnome-shell/extensions/${_uuid}/schemas" "$_schema_dir"
}
