# Template file for 'tlp'
pkgname=tlp
# Remember to update 'tlpui' asap.
version=1.10.1
revision=1
build_style=gnu-makefile
make_build_args="TLP_WITH_SYSTEMD=0 TLP_SBIN=/usr/bin
 TLP_ELOD=/usr/libexec/elogind/system-sleep"
make_install_args="${make_build_args}"
make_install_target="install install-man"
depends="hdparm bash iw util-linux ethtool perl"
short_desc="Advanced power management tool for Linux"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2.0-or-later"
homepage="https://linrunner.de/en/tlp/docs/tlp-linux-advanced-power-management.html"
changelog="https://raw.githubusercontent.com/linrunner/TLP/main/changelog"
distfiles="https://github.com/linrunner/TLP/archive/${version}.tar.gz"
checksum=c3f1f4b72a603a134e24b21364669a828180a3de5cbe62917ba88f0c53ca6397

conflicts="laptop-mode>=0 perl-Unicode-Tussle>=0"
conf_files="/etc/tlp.conf /etc/tlp.d/*.conf"
make_dirs="/var/lib/tlp 0755 root root"

post_install() {
	vinstall ${FILESDIR}/tlp.resume 755 etc/zzz.d/resume 50-tlp.sh
	vinstall ${FILESDIR}/tlp.suspend 755 etc/zzz.d/suspend 50-tlp.sh

	rm ${DESTDIR}/usr/share/man/man8/*.service.8
	rm -r ${DESTDIR}/etc/init.d
	rm -r ${DESTDIR}/usr/lib/systemd
	vsv tlp
}

tlp-pd_package() {
	short_desc="TLP Profiles Daemon"
	conf_files="/etc/tlp-pd.dbus.conf"
	depends="tlp python3-gobject polkit"

	conflicts="power-profiles-daemon>=0"

	pkg_install() {
		vconf tlp-pd.dbus.conf
		vmove usr/bin/tlp-pd
		vmove usr/bin/tlpctl
		vmove usr/share/man/man1/tlpctl.1
		vmove usr/share/man/man8/tlp-pd.8
		vmove "usr/share/dbus-1/system.d/*.conf"
		vmove "usr/share/dbus-1/system-services/*.service"
		vmove usr/share/polkit-1/actions/tlp-pd.policy
		vsv tlp-pd
	}
}

tlp-rdw_package() {
	short_desc="Control the radio device wizard"
	depends="tlp NetworkManager"

	pkg_install() {
		vmove usr/bin/tlp-rdw
		vmove usr/lib/udev/rules.d/85-tlp-rdw.rules
		vmove usr/lib/udev/tlp-rdw-udev
		vmove usr/lib/NetworkManager/dispatcher.d/99tlp-rdw-nm
		vmove usr/share/man/man8/tlp-rdw.8
	}
}
