Gentoo Archives: gentoo-commits

From: Christoph Junghans <ottxor@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-laptop/tpacpi-bat/, app-laptop/tpacpi-bat/files/
Date: Tue, 23 Aug 2016 23:10:50
Message-Id: 1471993826.73f8d9c4c42ac55b3c079749dde927ed5252448f.ottxor@gentoo
1 commit: 73f8d9c4c42ac55b3c079749dde927ed5252448f
2 Author: nemunaire <nemunaire <AT> nemunai <DOT> re>
3 AuthorDate: Mon Jul 11 23:45:03 2016 +0000
4 Commit: Christoph Junghans <ottxor <AT> gentoo <DOT> org>
5 CommitDate: Tue Aug 23 23:10:26 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=73f8d9c4
7
8 app-laptop/tpacpi-bat: battery number in configuration instead of init script
9
10 close #1857 gh
11
12 app-laptop/tpacpi-bat/files/tpacpi-bat.confd.1 | 19 ++++++
13 app-laptop/tpacpi-bat/files/tpacpi-bat.initd.2 | 76 ++++++++++++++++++++++
14 ...pi-bat-9999.ebuild => tpacpi-bat-3.0-r1.ebuild} | 10 +--
15 app-laptop/tpacpi-bat/tpacpi-bat-9999.ebuild | 10 +--
16 4 files changed, 105 insertions(+), 10 deletions(-)
17
18 diff --git a/app-laptop/tpacpi-bat/files/tpacpi-bat.confd.1 b/app-laptop/tpacpi-bat/files/tpacpi-bat.confd.1
19 new file mode 100644
20 index 00000000..f1faf1d
21 --- /dev/null
22 +++ b/app-laptop/tpacpi-bat/files/tpacpi-bat.confd.1
23 @@ -0,0 +1,19 @@
24 +# /etc/conf.d/tpacpi-bat: config file for /etc/init.d/tpacpi-bat
25 +
26 +# use '/etc/init.d/tpacpi-bat info' at any time to check the thresholds
27 +# currently used by the driver
28 +
29 +# list of batteries the script should manage
30 +# for example: BATS="1 2"
31 +BATS="1"
32 +
33 +# default thresholds for '/etc/init.d/tpacpi-bat start'
34 +TPACPI_BAT_THRESH_START="30"
35 +TPACPI_BAT_THRESH_STOP="85"
36 +# values to be used for '/etc/init.d/tpacpi-bat low'
37 +TPACPI_BAT_LOW_THRESH_START="${TPACPI_BAT_THRESH_START}"
38 +TPACPI_BAT_LOW_THRESH_STOP="${TPACPI_BAT_THRESH_STOP}"
39 +
40 +# values to be used for '/etc/init.d/tpacpi-bat high'
41 +TPACPI_BAT_HIGH_THRESH_START="95"
42 +TPACPI_BAT_HIGH_THRESH_STOP="99" #see bug #485526
43
44 diff --git a/app-laptop/tpacpi-bat/files/tpacpi-bat.initd.2 b/app-laptop/tpacpi-bat/files/tpacpi-bat.initd.2
45 new file mode 100644
46 index 00000000..796b94a
47 --- /dev/null
48 +++ b/app-laptop/tpacpi-bat/files/tpacpi-bat.initd.2
49 @@ -0,0 +1,76 @@
50 +#!/sbin/openrc-run
51 +# Copyright (C) 2012-2013 Christoph Junghans <ottxor@g.o>
52 +#
53 +# Distributed under the terms of the GNU General Public License, v2 or later
54 +
55 +extra_started_commands="low high info"
56 +
57 +depend() {
58 + after modules
59 +}
60 +
61 +start() {
62 + local state1
63 +
64 + ebegin "Making sure that module 'acpi_call' is loaded"
65 + modprobe acpi_call
66 + state1=$?
67 + eend ${state1}
68 +
69 + [ "${state1}" -ne "0" ] && return 1
70 +
71 + ebegin "Starting ${SVCNAME}"
72 + set_all ${TPACPI_BAT_THRESH_START} ${TPACPI_BAT_THRESH_STOP}
73 + eend $?
74 +}
75 +
76 +stop() {
77 + einfo "Nothing required to be done to stop ${SVCNAME}"
78 +}
79 +
80 +require_started() {
81 + if ! service_started; then
82 + "${RC_SERVICE}" start || return $?
83 + fi
84 +}
85 +
86 +high() {
87 + require_started
88 +
89 + einfo "Switching ${SVCNAME} to high thesholds"
90 + set_all ${TPACPI_BAT_HIGH_THRESH_START} ${TPACPI_BAT_HIGH_THRESH_STOP}
91 +}
92 +
93 +low() {
94 + require_started
95 +
96 + einfo "Switching ${SVCNAME} to low thesholds"
97 + set_all ${TPACPI_BAT_LOW_THRESH_START} ${TPACPI_BAT_LOW_THRESH_STOP}
98 +}
99 +
100 +set_all() {
101 + local tstart=$1
102 + local tstop=$2
103 + local bat
104 +
105 + for bat in ${BATS}; do
106 + ebegin " setting thresholds for ${bat}: $tstart $tstop"
107 + /usr/bin/tpacpi-bat -s startThreshold ${bat} ${tstart}
108 + /usr/bin/tpacpi-bat -s stopThreshold ${bat} ${tstop}
109 + eend $?
110 + done
111 +}
112 +
113 +info() {
114 + local tstart
115 + local tstop
116 + local bat
117 +
118 + require_started
119 +
120 + for bat in ${BATS}; do
121 + tstart=$(/usr/bin/tpacpi-bat -g startThreshold ${bat})
122 + tstop=$(/usr/bin/tpacpi-bat -g stopThreshold ${bat})
123 + einfo "Battery ${bat}: ${tstart} ${tstop}"
124 + done
125 +}
126
127 diff --git a/app-laptop/tpacpi-bat/tpacpi-bat-9999.ebuild b/app-laptop/tpacpi-bat/tpacpi-bat-3.0-r1.ebuild
128 similarity index 81%
129 copy from app-laptop/tpacpi-bat/tpacpi-bat-9999.ebuild
130 copy to app-laptop/tpacpi-bat/tpacpi-bat-3.0-r1.ebuild
131 index 5164010..1b30cbd 100644
132 --- a/app-laptop/tpacpi-bat/tpacpi-bat-9999.ebuild
133 +++ b/app-laptop/tpacpi-bat/tpacpi-bat-3.0-r1.ebuild
134 @@ -1,10 +1,10 @@
135 -# Copyright 1999-2013 Gentoo Foundation
136 +# Copyright 1999-2016 Gentoo Foundation
137 # Distributed under the terms of the GNU General Public License v2
138 # $Id$
139
140 -EAPI=5
141 +EAPI=6
142
143 -inherit eutils systemd
144 +inherit systemd
145
146 if [ "${PV}" = "9999" ]; then
147 inherit git-2
148 @@ -28,7 +28,7 @@ RDEPEND="sys-power/acpi_call
149 src_install() {
150 dodoc README battery_asl
151 dobin tpacpi-bat
152 - newinitd "${FILESDIR}"/${PN}.initd.1 ${PN}
153 - newconfd "${FILESDIR}"/${PN}.confd.0 ${PN}
154 + newinitd "${FILESDIR}"/${PN}.initd.2 ${PN}
155 + newconfd "${FILESDIR}"/${PN}.confd.1 ${PN}
156 systemd_newunit tpacpi.service ${PN}.service
157 }
158
159 diff --git a/app-laptop/tpacpi-bat/tpacpi-bat-9999.ebuild b/app-laptop/tpacpi-bat/tpacpi-bat-9999.ebuild
160 index 5164010..1b30cbd 100644
161 --- a/app-laptop/tpacpi-bat/tpacpi-bat-9999.ebuild
162 +++ b/app-laptop/tpacpi-bat/tpacpi-bat-9999.ebuild
163 @@ -1,10 +1,10 @@
164 -# Copyright 1999-2013 Gentoo Foundation
165 +# Copyright 1999-2016 Gentoo Foundation
166 # Distributed under the terms of the GNU General Public License v2
167 # $Id$
168
169 -EAPI=5
170 +EAPI=6
171
172 -inherit eutils systemd
173 +inherit systemd
174
175 if [ "${PV}" = "9999" ]; then
176 inherit git-2
177 @@ -28,7 +28,7 @@ RDEPEND="sys-power/acpi_call
178 src_install() {
179 dodoc README battery_asl
180 dobin tpacpi-bat
181 - newinitd "${FILESDIR}"/${PN}.initd.1 ${PN}
182 - newconfd "${FILESDIR}"/${PN}.confd.0 ${PN}
183 + newinitd "${FILESDIR}"/${PN}.initd.2 ${PN}
184 + newconfd "${FILESDIR}"/${PN}.confd.1 ${PN}
185 systemd_newunit tpacpi.service ${PN}.service
186 }