# Maintainer: Gregory Land
# Contributor: Fabian Bornschein <fabiscafe-cat-mailbox-dog-com>

pkgname=supergfxctl
pkgver=5.2.7
pkgrel=3
pkgdesc="A utility for Linux graphics switching on Intel/AMD iGPU + nVidia dGPU laptops"
arch=('x86_64')
url="https://gitlab.com/asus-linux/supergfxctl"
license=('MPL-2.0')
depends=('gcc-libs' 'systemd' 'lsof')
makedepends=('rust')
provides=('supergfxctl')
conflicts=('supergfxctl-git'
	'optimus-manager')
source=("https://gitlab.com/asus-linux/supergfxctl/-/archive/$pkgver/supergfxctl-$pkgver.tar.gz"
	"drop-nonexistent-sudo-group.patch")
sha512sums=('bd94646d289c9f3398e1bf2a189554ac60d4db2d4d2cefddc0b342e8a128d4682e20268e0b1f9b168441136ada0b6fadb097a5a35d1023a77528dbf0540de3af'
	'c24de0e6a632fd98052eb3b265000cf15bf00ff46f7e52120e462715937df8135297d9f12725d1c303691c0db55b23d2b29671f020bd64e98a993b1ad9b8551e')
options=(!debug)
_gitdir=${pkgname%"-git"}

prepare() {
	cd "$pkgname-$pkgver"
	# Arch has no "sudo" group, so dbus-broker rejects that policy block by name on
	# every bus reload ("Invalid group-name ... group=\"sudo\""). The block grants
	# nothing here; the wheel policy in the same file is the one that applies.
	patch -p1 -i "$srcdir/drop-nonexistent-sudo-group.patch"
}

build() {
	cd "$pkgname-$pkgver"
	make build
}

package() {
	cd "$pkgname-$pkgver"
	make DESTDIR="$pkgdir" install
}
