public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: app-laptop/tpacpi-bat/, app-laptop/tpacpi-bat/files/
@ 2016-08-23 23:10 Christoph Junghans
  0 siblings, 0 replies; only message in thread
From: Christoph Junghans @ 2016-08-23 23:10 UTC (permalink / raw
  To: gentoo-commits

commit:     73f8d9c4c42ac55b3c079749dde927ed5252448f
Author:     nemunaire <nemunaire <AT> nemunai <DOT> re>
AuthorDate: Mon Jul 11 23:45:03 2016 +0000
Commit:     Christoph Junghans <ottxor <AT> gentoo <DOT> org>
CommitDate: Tue Aug 23 23:10:26 2016 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=73f8d9c4

app-laptop/tpacpi-bat: battery number in configuration instead of init script

close #1857 gh

 app-laptop/tpacpi-bat/files/tpacpi-bat.confd.1     | 19 ++++++
 app-laptop/tpacpi-bat/files/tpacpi-bat.initd.2     | 76 ++++++++++++++++++++++
 ...pi-bat-9999.ebuild => tpacpi-bat-3.0-r1.ebuild} | 10 +--
 app-laptop/tpacpi-bat/tpacpi-bat-9999.ebuild       | 10 +--
 4 files changed, 105 insertions(+), 10 deletions(-)

diff --git a/app-laptop/tpacpi-bat/files/tpacpi-bat.confd.1 b/app-laptop/tpacpi-bat/files/tpacpi-bat.confd.1
new file mode 100644
index 00000000..f1faf1d
--- /dev/null
+++ b/app-laptop/tpacpi-bat/files/tpacpi-bat.confd.1
@@ -0,0 +1,19 @@
+# /etc/conf.d/tpacpi-bat: config file for /etc/init.d/tpacpi-bat
+
+# use '/etc/init.d/tpacpi-bat info' at any time to check the thresholds
+# currently used by the driver
+
+# list of batteries the script should manage
+# for example: BATS="1 2"
+BATS="1"
+
+# default thresholds for '/etc/init.d/tpacpi-bat start'
+TPACPI_BAT_THRESH_START="30"
+TPACPI_BAT_THRESH_STOP="85"
+# values to be used for '/etc/init.d/tpacpi-bat low'
+TPACPI_BAT_LOW_THRESH_START="${TPACPI_BAT_THRESH_START}"
+TPACPI_BAT_LOW_THRESH_STOP="${TPACPI_BAT_THRESH_STOP}"
+
+# values to be used for '/etc/init.d/tpacpi-bat high'
+TPACPI_BAT_HIGH_THRESH_START="95"
+TPACPI_BAT_HIGH_THRESH_STOP="99" #see bug #485526

diff --git a/app-laptop/tpacpi-bat/files/tpacpi-bat.initd.2 b/app-laptop/tpacpi-bat/files/tpacpi-bat.initd.2
new file mode 100644
index 00000000..796b94a
--- /dev/null
+++ b/app-laptop/tpacpi-bat/files/tpacpi-bat.initd.2
@@ -0,0 +1,76 @@
+#!/sbin/openrc-run
+# Copyright (C) 2012-2013 Christoph Junghans <ottxor@gentoo.org>
+#
+# Distributed under the terms of the GNU General Public License, v2 or later
+
+extra_started_commands="low high info"
+
+depend() {
+	after modules
+}
+
+start() {
+	local state1
+
+	ebegin "Making sure that module 'acpi_call' is loaded"
+	modprobe acpi_call
+	state1=$?
+	eend ${state1}
+
+	[ "${state1}" -ne "0" ] && return 1
+
+	ebegin "Starting ${SVCNAME}"
+	set_all ${TPACPI_BAT_THRESH_START} ${TPACPI_BAT_THRESH_STOP}
+	eend $?
+}
+
+stop() {
+	einfo "Nothing required to be done to stop ${SVCNAME}"
+}
+
+require_started() {
+	if ! service_started; then
+		"${RC_SERVICE}" start || return $?
+	fi
+}
+
+high() {
+	require_started
+
+	einfo "Switching ${SVCNAME} to high thesholds"
+	set_all ${TPACPI_BAT_HIGH_THRESH_START} ${TPACPI_BAT_HIGH_THRESH_STOP}
+}
+
+low() {
+	require_started
+
+	einfo "Switching ${SVCNAME} to low thesholds"
+	set_all ${TPACPI_BAT_LOW_THRESH_START} ${TPACPI_BAT_LOW_THRESH_STOP}
+}
+
+set_all() {
+	local tstart=$1
+	local tstop=$2
+	local bat
+
+	for bat in ${BATS}; do
+		ebegin "  setting thresholds for ${bat}: $tstart $tstop"
+		/usr/bin/tpacpi-bat -s startThreshold ${bat} ${tstart}
+		/usr/bin/tpacpi-bat -s stopThreshold ${bat} ${tstop}
+		eend $?
+	done
+}
+
+info() {
+	local tstart
+	local tstop
+	local bat
+
+	require_started
+
+	for bat in ${BATS}; do
+		tstart=$(/usr/bin/tpacpi-bat -g startThreshold ${bat})
+		tstop=$(/usr/bin/tpacpi-bat -g stopThreshold ${bat})
+		einfo "Battery ${bat}: ${tstart} ${tstop}"
+	done
+}

diff --git a/app-laptop/tpacpi-bat/tpacpi-bat-9999.ebuild b/app-laptop/tpacpi-bat/tpacpi-bat-3.0-r1.ebuild
similarity index 81%
copy from app-laptop/tpacpi-bat/tpacpi-bat-9999.ebuild
copy to app-laptop/tpacpi-bat/tpacpi-bat-3.0-r1.ebuild
index 5164010..1b30cbd 100644
--- a/app-laptop/tpacpi-bat/tpacpi-bat-9999.ebuild
+++ b/app-laptop/tpacpi-bat/tpacpi-bat-3.0-r1.ebuild
@@ -1,10 +1,10 @@
-# Copyright 1999-2013 Gentoo Foundation
+# Copyright 1999-2016 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-EAPI=5
+EAPI=6
 
-inherit eutils systemd
+inherit systemd
 
 if [ "${PV}" = "9999" ]; then
 	inherit git-2
@@ -28,7 +28,7 @@ RDEPEND="sys-power/acpi_call
 src_install() {
 	dodoc README battery_asl
 	dobin tpacpi-bat
-	newinitd "${FILESDIR}"/${PN}.initd.1 ${PN}
-	newconfd "${FILESDIR}"/${PN}.confd.0 ${PN}
+	newinitd "${FILESDIR}"/${PN}.initd.2 ${PN}
+	newconfd "${FILESDIR}"/${PN}.confd.1 ${PN}
 	systemd_newunit tpacpi.service ${PN}.service
 }

diff --git a/app-laptop/tpacpi-bat/tpacpi-bat-9999.ebuild b/app-laptop/tpacpi-bat/tpacpi-bat-9999.ebuild
index 5164010..1b30cbd 100644
--- a/app-laptop/tpacpi-bat/tpacpi-bat-9999.ebuild
+++ b/app-laptop/tpacpi-bat/tpacpi-bat-9999.ebuild
@@ -1,10 +1,10 @@
-# Copyright 1999-2013 Gentoo Foundation
+# Copyright 1999-2016 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-EAPI=5
+EAPI=6
 
-inherit eutils systemd
+inherit systemd
 
 if [ "${PV}" = "9999" ]; then
 	inherit git-2
@@ -28,7 +28,7 @@ RDEPEND="sys-power/acpi_call
 src_install() {
 	dodoc README battery_asl
 	dobin tpacpi-bat
-	newinitd "${FILESDIR}"/${PN}.initd.1 ${PN}
-	newconfd "${FILESDIR}"/${PN}.confd.0 ${PN}
+	newinitd "${FILESDIR}"/${PN}.initd.2 ${PN}
+	newconfd "${FILESDIR}"/${PN}.confd.1 ${PN}
 	systemd_newunit tpacpi.service ${PN}.service
 }


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-08-23 23:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-23 23:10 [gentoo-commits] repo/gentoo:master commit in: app-laptop/tpacpi-bat/, app-laptop/tpacpi-bat/files/ Christoph Junghans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox