# Maintainer: Vincent.Ducamps <aur@ducamps.eu>
# Co-Maintainer: Mark Wagie <mark dot wagie at proton dot me>
pkgname=gnome-shell-extension-pop-shell-git
pkgver=1.2.0.r315.g3cb093b
pkgrel=1
pkgdesc="GNOME Shell extension for advanced tiling window management"
arch=('any')
url="https://github.com/pop-os/shell"
license=('GPL-3.0-or-later')
depends=(
  'fd'
  'gnome-shell'
  'pop-launcher-git'
  'pop-shell-shortcuts-git'
  'xorg-xprop'
)
makedepends=(
  'git'
  'typescript'
)
optdepends=(
  'gnome-control-center: keybinding categories'
  'gnome-shell-extensions: for Native Window Placment extension'
)
provides=("${pkgname%-git}")
conflicts=("${pkgname%-git}")
source=('git+https://github.com/pop-os/shell.git#branch=master_noble'
  '0001-Remove-schema-handling-from-transpile.sh.patch'
  '50_org.gnome.desktop.wm.keybindings.pop-shell.gschema.override'
  '50_org.gnome.mutter.pop-shell.gschema.override'
  '50_org.gnome.mutter.wayland.pop-shell.gschema.override'
  '50_org.gnome.settings-daemon.plugins.media-keys.pop-shell.gschema.override'
  '50_org.gnome.shell.pop-shell.gschema.override')
sha256sums=('SKIP'
  '84b5132edab34ca1af33e310838ad1e430e2ed796da4ec9d3ab646b9f61a71cf'
  '6801f3e12a539167a0c2b64c7deccc1726b51e681b0bc932e8a5f628f86e69df'
  'fcddff7a7689ea0f9ac3d983d224d347e093d5eda1c7c1d875133248f8b812c0'
  'd3a4ac86303c9065fd76dace64283573079c3bdce4b9a2ca18be5f103eb6fd4c'
  '77f854c2f4509ed83d3d99a40018914f031f61f945e1acbf527fcc65adb5f252'
  '7b729a10fe29f2af7bac3022d87fece43ed4094b3ad2a9ac3a61ffc465dadde1')

pkgver() {
  cd shell
  git describe --long --tags --abbrev=7 | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
  cd shell
  patch -Np1 -i ../0001-Remove-schema-handling-from-transpile.sh.patch

  # Fix the title bar showing/hiding
  git cherry-pick -n 3386f426b1750a166c767c583dcb69ed2997234f
}

build() {
  cd shell
  make
}

package() {
  cd shell
  make DESTDIR="$pkgdir" install

  # install the schema file
  install -Dm644 schemas/org.gnome.shell.extensions.pop-shell.gschema.xml -t \
    "$pkgdir/usr/share/glib-2.0/schemas/"

  # install the gnome-control-center keybindings
  install -Dm644 keybindings/*.xml -t \
    "$pkgdir/usr/share/gnome-control-center/keybindings/"

  # install the schema override files
  install -Dm644 "$srcdir"/*.pop-shell.gschema.override -t \
    "$pkgdir/usr/share/glib-2.0/schemas/"
}
