app-laptop/tpacpi-bat: Move BATS variable into conf.d

Because some Thinkpad have more than one battery.

Package-Manager: portage-2.2.26
This commit is contained in:
nemunaire 2016-04-13 21:07:19 +01:00
parent a60dcadc78
commit 482f4bdd05
5 changed files with 145 additions and 0 deletions

View File

@ -0,0 +1,5 @@
AUX tpacpi-bat.confd.0 668 SHA256 23fbfd271bb0a30c621b620307222efc4eb51f74904f7bae75a9942fe9e899e5 SHA512 570824184f85e9f4b687e67131165671389b836d94f15edbd4bd14c77b0c6546c2991da25bc0172ccdee03cc8c0ad82c378e982e147334e9cb83334d0382038b WHIRLPOOL 7db522f8d08c99f68ba61d46144948b24db889882adf7bea8ccfadc14c1b21b8ce9d6a526a4c611df25e184dee28f3686ecf2eee70ac746916a0c137e7045d04
AUX tpacpi-bat.initd.1 1485 SHA256 3d490db3c3382e670a6694839dd4d68a9479e6670dc3624c3d80d42e2e57bb96 SHA512 5f5462e9ec38f88ca420ee91392e83d48feb63fe6150b2d19200010b9ecd144ff724b1f3d72063bcb26829a96c6087d0e681b641f490690ee1e854e33d89f452 WHIRLPOOL 0844a613e1fc491e57c6ad222a9b28c1f950801284ae2067aa743233e2ee2d4dc508555ba6a0041895a199b391cbb98da53f8b275ed98a116e4702732538578d
DIST tpacpi-bat-3.0.tar.gz 18137 SHA256 f9aa8be181df6a7d41eac6224abb6dadf1d147022449e9159c4aa09397b7a485 SHA512 2beab3e5495f028b53d673a4243a2128f4ff85e19e18ac7d53663a1d62e20b271442d6c2c8f19cb41d618ddf7ebb4d9b8390f7f185f77bdca33c69bb19463128 WHIRLPOOL 9329ea83fdd0913cc47446895e6ab385f09ca42e7a19533b5c7fa44cb62bebd07ba24f89b0deacc89d6b3aff3ff826f2a53f8d2e918f137d0f6215aa6eaa9198
EBUILD tpacpi-bat-3.0-r1.ebuild 854 SHA256 fdfc616d11119b8c7d4166eeaa3ca123337fbbbb19a91e2fa033bf52986ea6ff SHA512 6a58873f2fb6761e1bff6e20c4b20b5a2c50c968e23e682b25dd0d6fa1bff67714856fe96179081b76ca9992dbbdbb84cd312c86861b27b780ce542f2c02d70c WHIRLPOOL ecf1f8f8ac22abc12ddf4e9cf04e3bdc662fa12a9f6cdbd55211332bd8c7fb2cff8ad7b53369c09821f2d64796cf3e67a7f8431afdbde7d9c48551a614eb1ef9
MISC metadata.xml 336 SHA256 dec541eaeca510bc42413503d45d26cbea4db1b41a2ee81479e58af3002e9d59 SHA512 01048c76d5f27ab31637351e2f332f57e53b83a7eac350974c7cd7308043f4e29f7fc578c9cf1c17e95a73f3ce9d6eece44e611a9dbb3a3badbe27e1da630ccd WHIRLPOOL 804f0faa7a417442e2ec61fdefd10bbe1b5c5e457342175808d63ee8ed7914d920c175f91cdff49d5bc8a7d603079df408239cb16479a1c882d5635313b1c362

View File

@ -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

View File

@ -0,0 +1,76 @@
#!/sbin/runscript
# 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
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="person">
<email>ottxor@gentoo.org</email>
<name>Christoph Junghans</name>
</maintainer>
<upstream>
<remote-id type="github">teleshoes/tpacpi-bat</remote-id>
</upstream>
</pkgmetadata>

View File

@ -0,0 +1,34 @@
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
EAPI=5
inherit eutils systemd
if [ "${PV}" = "9999" ]; then
inherit git-2
EGIT_REPO_URI="git://github.com/teleshoes/tpacpi-bat.git https://github.com/teleshoes/tpacpi-bat.git"
KEYWORDS=""
else
SRC_URI="https://github.com/teleshoes/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
KEYWORDS="~amd64"
fi
DESCRIPTION="Control battery thresholds of recent ThinkPads, which are not supported by tp_smapi"
HOMEPAGE="https://github.com/teleshoes/tpacpi-bat"
LICENSE="GPL-3"
SLOT="0"
IUSE=""
DEPEND=""
RDEPEND="sys-power/acpi_call
dev-lang/perl"
src_install() {
dodoc README battery_asl
dobin tpacpi-bat
newinitd "${FILESDIR}"/${PN}.initd.1 ${PN}
newconfd "${FILESDIR}"/${PN}.confd.0 ${PN}
systemd_newunit tpacpi.service ${PN}.service
}