Merge lp://qastaging/~raphink/byobu/353215 into lp://qastaging/byobu

Proposed by Raphaël Pinson
Status: Merged
Merge reported by: Dustin Kirkland 
Merged at revision: not available
Proposed branch: lp://qastaging/~raphink/byobu/353215
Merge into: lp://qastaging/byobu
Diff against target: None lines
To merge this branch: bzr merge lp://qastaging/~raphink/byobu/353215
Reviewer Review Type Date Requested Status
Dustin Kirkland  Disapprove
Review via email: mp+5109@code.qastaging.launchpad.net
To post a comment you must log in.
lp://qastaging/~raphink/byobu/353215 updated
284. By Raphaël Pinson <raphink@rpinson>

Display "/!\" for both warn and low alert. The color now makes the difference.

285. By Raphaël Pinson <raphink@rpinson>

Do not display /!\ since the colors indicate the criticity already

286. By Raphaël Pinson <raphink@rpinson>

Only + is useful:
  * Battery is discharging unless there is a "+";
  * Full is obvious when the percentage reaches 100.

287. By Raphaël Pinson <raphink@rpinson>

Apply the background to an ASCII art battery with a sign in it:
  * - for discharging
  * + for charging
  * = for full

Change the background color of the ASCII art battery only to reflect the state:
  * green: OK
  * orange: warn
  * red: low

288. By Raphaël Pinson <email address hidden>

Only use signs for +
Place the sign in front of the ASCII art instead of inside

Revision history for this message
Dustin Kirkland  (kirkland) wrote :

I believe that this merge has been superceded by another one, which I merged already.

Thanks for your contribution!

:-Dustin

review: Disapprove

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'bin/battery_state'
2--- bin/battery_state 1970-01-01 00:00:00 +0000
3+++ bin/battery_state 2009-04-01 15:47:40 +0000
4@@ -0,0 +1,85 @@
5+#!/bin/sh -e
6+#
7+# battery_state: print the state of the battery
8+# Copyright (C) 2009 Raphaël Pinson.
9+#
10+# Authors: Raphaël Pinson <raphink@ubuntu.com>
11+#
12+# This program is free software: you can redistribute it and/or modify
13+# it under the terms of the GNU General Public License as published by
14+# the Free Software Foundation, either version 3 of the License, or
15+# (at your option) any later version.
16+#
17+# This program is distributed in the hope that it will be useful,
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+# GNU General Public License for more details.
21+#
22+# You should have received a copy of the GNU General Public License
23+# along with this program. If not, see <http://www.gnu.org/licenses/>.
24+#
25+
26+
27+search () {
28+ local str expr
29+ str="$1"
30+ expr="$2"
31+
32+ echo "$str" | sed -n "s/${expr}/\1/p"
33+}
34+
35+
36+BATS=$(ls /proc/acpi/battery)
37+NB=$(echo "$BATS" | wc -l)
38+
39+for bat in $BATS; do
40+ if [ "$NB" -gt 1 ]; then
41+ echo -n "$bat: "
42+ fi
43+
44+ # read files once
45+ infofile=$(cat "/proc/acpi/battery/$bat/info")
46+ statefile=$(cat "/proc/acpi/battery/$bat/state")
47+
48+ present=$(search "$infofile" "present: *\(.*\)")
49+
50+ if [ "x${present}" = "xno" ]; then
51+ echo "n/a"
52+ break
53+ fi
54+
55+ full=$(search "$infofile" "last full capacity: *\(.*\) m[AW]h")
56+ warn=$(search "$infofile" "design capacity warning: \(.*\) m[AW]h")
57+ low=$(search "$infofile" "design capacity low: \(.*\) m[AW]h")
58+
59+ rem=$(search "$statefile" "remaining capacity: *\(.*\) m[AW]h")
60+ if [ "$rem" -lt "$low" ]; then
61+ alert="\005{=b .r}! "
62+ elif [ "$rem" -lt "$warn" ]; then
63+ alert="\005{= .y}/!\ "
64+ else
65+ alert=""
66+ fi
67+
68+ percent=$(echo "100*$rem/$full" | bc)
69+ state=$(search "$statefile" "charging state: *\(.*\)")
70+
71+ case $state in
72+ charging)
73+ sign="+"
74+ ;;
75+ discharging)
76+ sign="-"
77+ ;;
78+ charged)
79+ sign="="
80+ ;;
81+ *)
82+ sign=" $state"
83+ ;;
84+ esac
85+
86+ echo "${alert}${percent}%${sign}"
87+done
88+
89+

Subscribers

People subscribed via source and target branches