# Reference: https://postmarketos.org/uipkg
# Maintainer: Miles Alan <m@milesalan.com>
pkgname=sxmo-common
pkgver=1.13.0
pkgrel=1
pkgdesc="Simple Mobile: Core package to build custom SXMO desktop environments"
url="http://sr.ht/~mil/Sxmo"
arch="noarch !armhf"
license="MIT"
depends="
	adwaita-icon-theme
	alsa-utils
	callaudiod
	codemadness-frontends
	dnsmasq
	dunstify
	ffmpeg
	file
	font-fira-mono-nerd
	font-terminus-nerd
	geoclue
	inotify-tools
	light
	linux-tools-iio
	lisgd
	mediainfo
	mmsd-tng
	mmsd-tng-tools
	mnc
	modemmanager
	modemmanager-openrc
	mpv
	ncurses
	pamixer
	pnc
	polkit
	polkit-openrc
	postmarketos-base-ui
	postmarketos-base-ui-networkmanager
	pulseaudio-utils
	superd
	sxmo-common-audio
	sxmo-utils
	sxmo-utils-openrc
	terminus-font
	tinydm
	tinydm-openrc
	tzdata
	v4l-utils
	vim
	vvmd
	xdg-user-dirs
	yt-dlp
	"
install="$pkgname.post-install $pkgname.post-upgrade $pkgname.pre-deinstall"
subpackages="$pkgname-qt_tweaks $pkgname-bluetooth $pkgname-bluetoothpulse"
source="
	sxmo-qt-mobile-controls.sh
	postmarketos.conf
	"
options="!check" # has no tests

package() {
	mkdir -p "$pkgdir"
}

qt_tweaks() {
	install_if="$pkgname=$pkgver-r$pkgrel qt5-qtbase"
	install -Dm755 -t "$subpkgdir"/etc/profile.d/ \
		"$srcdir"/sxmo-qt-mobile-controls.sh
	provides="postmarketos-ui-sxmo-qt_tweaks=$pkgver-r$pkgrel"
}

bluetooth() {
	# Should configure pipewire for bluetooth headsets according to this
	# https://wiki.alpinelinux.org/wiki/PipeWire
	depends="
		dbus
		dbus-openrc
		dbus-x11
		bluez
		bluez-openrc
		pipewire-spa-bluez
		"
	replaces="bluez" # Autoenable controllers
	mkdir -p "$subpkgdir"/etc/bluetooth
	install -Dm644 "$srcdir"/postmarketos.conf \
		"$subpkgdir"/etc/bluetooth/main.conf
	mkdir -p "$subpkgdir"/etc/modules-load.d
	install="$subpkgname.post-install $subpkgname.pre-deinstall"
	provides="postmarketos-ui-sxmo-bluetooth=$pkgver-r$pkgrel"
}

bluetoothpulse() {
	depends="
		bluez
		pulseaudio-bluez
		!sxmo-common-bluetooth
		"
	replaces="bluez" # Autoenable controllers
	mkdir -p "$subpkgdir"/etc/bluetooth
	install -Dm644 "$srcdir"/postmarketos.conf \
		"$subpkgdir"/etc/bluetooth/main.conf
}

sha512sums="
bf8db527c49fa724e640a90269ba2648a2555f5867b2adbfbd88d1f685261f757339757c09ee08f590c76de4bd3d0c73a47dea9bd340644dd4707e76152cefd1  sxmo-qt-mobile-controls.sh
cc4e4404b135ce484e0976b243973e39f1137aa9dd5e9297f767b2ea65b719ca82e84cc66cb093950ce330dbf786981ced2e5b0d16350deb5706a08ffccb4606  postmarketos.conf
"
