Merge lp:~raphink/byobu/all into lp:byobu

Proposed by Raphaël Pinson
Status: Merged
Merged at revision: not available
Proposed branch: lp:~raphink/byobu/all
Merge into: lp:byobu
Diff against target: None lines
To merge this branch: bzr merge lp:~raphink/byobu/all
Reviewer Review Type Date Requested Status
Dustin Kirkland  Pending
Review via email: mp+5150@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Raphaël Pinson (raphink) wrote :

Since this branch contains the battery script as well as two new scripts, you can ignore the request to merge from the specific branch for battery_state (https://code.launchpad.net/~raphink/screen-profiles/353215/+merge/5109).

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 16:56:50 +0000
4@@ -0,0 +1,86 @@
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+ color="\005{= r.}"
62+ elif [ "$rem" -lt "$warn" ]; then
63+ color="\005{= y.}"
64+ else
65+ color="\005{= g.}"
66+ fi
67+
68+
69+ percent=$(echo "100*$rem/$full" | bc)
70+ state=$(search "$statefile" "charging state: *\(.*\)")
71+
72+ case $state in
73+ charging)
74+ sign="+"
75+ ;;
76+ discharging)
77+ sign="-"
78+ ;;
79+ charged)
80+ sign="="
81+ ;;
82+ *)
83+ sign="$state"
84+ ;;
85+ esac
86+
87+ echo "${color}|${sign}|\005{-}${percent}%"
88+done
89+
90+
91
92=== added file 'bin/nb-users'
93--- bin/nb-users 1970-01-01 00:00:00 +0000
94+++ bin/nb-users 2009-04-02 15:18:17 +0000
95@@ -0,0 +1,23 @@
96+#!/bin/sh -e
97+#
98+# nb_users: print the number of users on the machine
99+# Copyright (C) 2009 Raphaël Pinson.
100+#
101+# Authors: Raphaël Pinson <raphink@ubuntu.com>
102+#
103+# This program is free software: you can redistribute it and/or modify
104+# it under the terms of the GNU General Public License as published by
105+# the Free Software Foundation, either version 3 of the License, or
106+# (at your option) any later version.
107+#
108+# This program is distributed in the hope that it will be useful,
109+# but WITHOUT ANY WARRANTY; without even the implied warranty of
110+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
111+# GNU General Public License for more details.
112+#
113+# You should have received a copy of the GNU General Public License
114+# along with this program. If not, see <http://www.gnu.org/licenses/>.
115+#
116+
117+uptime | sed -e "s/.*, *\(.* user[s]*\), .*/\1/"
118+
119
120=== added file 'bin/uptime'
121--- bin/uptime 1970-01-01 00:00:00 +0000
122+++ bin/uptime 2009-04-02 15:18:17 +0000
123@@ -0,0 +1,23 @@
124+#!/bin/sh -e
125+#
126+# uptime: condensed uptime of the machine
127+# Copyright (C) 2009 Raphaël Pinson.
128+#
129+# Authors: Raphaël Pinson <raphink@ubuntu.com>
130+#
131+# This program is free software: you can redistribute it and/or modify
132+# it under the terms of the GNU General Public License as published by
133+# the Free Software Foundation, either version 3 of the License, or
134+# (at your option) any later version.
135+#
136+# This program is distributed in the hope that it will be useful,
137+# but WITHOUT ANY WARRANTY; without even the implied warranty of
138+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
139+# GNU General Public License for more details.
140+#
141+# You should have received a copy of the GNU General Public License
142+# along with this program. If not, see <http://www.gnu.org/licenses/>.
143+#
144+
145+uptime | sed -e "s/.* up *\(.*\), *.* user[s]*, .*/\1/; s/ day[s]*, */d/"
146+

Subscribers

People subscribed via source and target branches