Merge lp:~jamesodhunt/byobu/unicode-enhancements into lp:byobu

Proposed by James Hunt
Status: Merged
Merged at revision: 1297
Proposed branch: lp:~jamesodhunt/byobu/unicode-enhancements
Merge into: lp:byobu
Diff against target: 978 lines (+921/-2)
7 files modified
debian/changelog (+13/-0)
usr/lib/byobu/Makefile.am (+1/-1)
usr/lib/byobu/uclock (+173/-0)
usr/lib/byobu/ugraph (+212/-0)
usr/lib/byobu/ulevel (+481/-0)
usr/lib/byobu/wastebasket (+39/-0)
usr/lib/byobu/wifi_quality (+2/-1)
To merge this branch: bzr merge lp:~jamesodhunt/byobu/unicode-enhancements
Reviewer Review Type Date Requested Status
Dustin Kirkland  Pending
Review via email: mp+48561@code.launchpad.net

Description of the change

  [ James Hunt <email address hidden> ]

  * usr/lib/byobu/uclock: New UTF-8 notification showing time in binary
    (requires bash) (LP: #705037).
  * usr/lib/byobu/ugraph: New UTF-8 notification utility showing historical
    ulevel data (required bash).
  * usr/lib/byobu/ulevel: New UTF-8 notification utility which displays
    some 'level' using various unicode characters (requires bash)
    (LP: #705032).
  * usr/lib/byobu/wastebasket: New ASCII+UTF-8 notification indicating
    contents of wastebasket.
  * usr/lib/byobu/wifi_quality: added UTF-8 icon.

Hi Dustin - lots of updates to the unicode notifications. You can now pass floating point values. I've got some test scripts that could be added at a later stage maybe?

Cheers,

James.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2011-02-01 19:24:03 +0000
+++ debian/changelog 2011-02-03 23:10:35 +0000
@@ -1,9 +1,22 @@
1byobu (3.28) unreleased; urgency=low1byobu (3.28) unreleased; urgency=low
22
3 [ Dustin Kirkland ]
3 * usr/lib/byobu/wifi_quality: don't show wifi-quality if connectivity == 04 * usr/lib/byobu/wifi_quality: don't show wifi-quality if connectivity == 0
4 * usr/lib/byobu/disk_io: don't show disk_io if rate = 05 * usr/lib/byobu/disk_io: don't show disk_io if rate = 0
5 * usr/lib/byobu/services: finally fix that nagging, mysterious whitespace6 * usr/lib/byobu/services: finally fix that nagging, mysterious whitespace
67
8 [ James Hunt <james.hunt@ubuntu.com> ]
9 * usr/lib/byobu/uclock: New UTF-8 notification showing time in binary
10 (requires bash) (LP: #705037).
11 * usr/lib/byobu/ugraph: New UTF-8 notification utility showing historical
12 ulevel data (required bash).
13 * usr/lib/byobu/ulevel: New UTF-8 notification utility which displays
14 some 'level' using various unicode characters (requires bash)
15 (LP: #705032).
16 * usr/lib/byobu/wastebasket: New ASCII+UTF-8 notification indicating
17 contents of wastebasket.
18 * usr/lib/byobu/wifi_quality: added UTF-8 icon.
19
7 -- Dustin Kirkland <kirkland@ubuntu.com> Fri, 28 Jan 2011 17:12:27 -060020 -- Dustin Kirkland <kirkland@ubuntu.com> Fri, 28 Jan 2011 17:12:27 -0600
821
9byobu (3.27-0ubuntu1) natty; urgency=low22byobu (3.27-0ubuntu1) natty; urgency=low
1023
=== modified file 'usr/lib/byobu/Makefile.am'
--- usr/lib/byobu/Makefile.am 2010-11-19 02:43:19 +0000
+++ usr/lib/byobu/Makefile.am 2011-02-03 23:10:35 +0000
@@ -1,3 +1,3 @@
1libdirdir = $(prefix)/lib/@PACKAGE@1libdirdir = $(prefix)/lib/@PACKAGE@
2libdir_SCRIPTS = apport arch battery cpu_count cpu_freq cpu_temp custom date disk disk_io ec2_cost fan_speed hostname ip_address load_average logo mail mem_available mem_used menu network .notify_osd notify_osd processes raid rcs_cost reboot_required release services swap time time_utc updates_available uptime users whoami wifi_quality2libdir_SCRIPTS = apport arch battery cpu_count cpu_freq cpu_temp custom date disk disk_io ec2_cost fan_speed hostname ip_address load_average logo mail mem_available mem_used menu network .notify_osd notify_osd processes raid rcs_cost reboot_required release services swap time time_utc uclock ugraph ulevel updates_available uptime users wastebasket whoami wifi_quality
33
44
=== added file 'usr/lib/byobu/uclock'
--- usr/lib/byobu/uclock 1970-01-01 00:00:00 +0000
+++ usr/lib/byobu/uclock 2011-02-03 23:10:35 +0000
@@ -0,0 +1,173 @@
1#!/bin/bash -e
2#---------------------------------------------------------------------
3# Script to display a "binary clock" using unicode characters from the
4# braille block.
5#
6# Designed to work with the wonderful byoby(1) but can be run
7# stand-alone.
8#---------------------------------------------------------------------
9#
10# Copyright (C) 2011 Canonical Ltd.
11#
12# Author: James Hunt <james.hunt@canonical.com>
13#
14# This program is free software: you can redistribute it and/or modify
15# it under the terms of the GNU General Public License as published by
16# the Free Software Foundation, version 3 of the License.
17#
18# This program is distributed in the hope that it will be useful,
19# but WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21# GNU General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with this program. If not, see <http://www.gnu.org/licenses/>.
25#
26#---------------------------------------------------------------------
27
28script_name=${0##*/}
29
30# Selected Unicode Braille characters:
31#
32# 0x2800, 0x2880, 0x2820, 0x28a0, 0x2810, 0x2890, 0x2830, 0x28b0, 0x2808, 0x2888,
33# 0x2840, 0x28c0, 0x2860, 0x28e0, 0x2850, 0x28d0, 0x2870, 0x28f0, 0x2848, 0x28c8,
34# 0x2804, 0x2884, 0x2824, 0x28a4, 0x2814, 0x2894, 0x2834, 0x28b4, 0x280c, 0x288c,
35# 0x2844, 0x28c4, 0x2864, 0x28e4, 0x2854, 0x28d4, 0x287b, 0x28f4, 0x284c, 0x28cc,
36# 0x2802, 0x2882, 0x2822, 0x28a2, 0x2812, 0x2892, 0x2832, 0x28b2, 0x280a, 0x288a,
37# 0x2842, 0x28c2, 0x2862, 0x28e2, 0x2852, 0x28d2, 0x2872, 0x28f2, 0x284a, 0x28ca,
38# 0x2806, 0x2886
39#
40# Index of this array is 0-61 with character returned being
41# "two column" binary representation of a time segment.
42#
43binary=(⠀ ⢀ ⠠ ⢠ ⠐ ⢐ ⠰ ⢰ ⠈ ⢈ \
44 ⡀ ⣀ ⡠ ⣠ ⡐ ⣐ ⡰ ⣰ ⡈ ⣈ \
45 ⠄ ⢄ ⠤ ⢤ ⠔ ⢔ ⠴ ⢴ ⠌ ⢌ \
46 ⡄ ⣄ ⡤ ⣤ ⡔ ⣔ ⡻ ⣴ ⡌ ⣌ \
47 ⠂ ⢂ ⠢ ⢢ ⠒ ⢒ ⠲ ⢲ ⠊ ⢊ \
48 ⡂ ⣂ ⡢ ⣢ ⡒ ⣒ ⡲ ⣲ ⡊ ⣊ ⠆ ⢆)
49
50usage()
51{
52cat <<EOT
53Description: A clock that displays the time in binary.
54
55Usage: $script_name [options]
56
57
58Options:
59
60 -b : Display binary clock (default)
61 -h : Show this help.
62 -l : Display leading zeros (hex and octal modes only).
63 -m : Show time in 24-hour military format
64 (default: 12-hour format).
65 -n : Suppress newline at end of time.
66 -o : Display time in octal (base 8).
67 -s <sep> : Specify separator between hours and minutes
68 (and seconds if not disabled).
69 -u : Display alphabetics in upper-case (hex mode only).
70 -x : Disable time in hexadecimal (base 16).
71 -z : Disable display of seconds.
72
73EOT
74}
75
76suppress_seconds=n
77clock_type=binary
78format=std
79ending="\n"
80uppercase=n
81leading_zeros=n
82
83while getopts "bhlmnos:uxz" opt
84do
85 case "$opt" in
86 b)
87 clock_type=binary
88 ;;
89
90 h)
91 usage
92 exit 0
93 ;;
94
95 l)
96 leading_zeros=y
97 ;;
98
99 m)
100 format=mil
101 ;;
102
103 n)
104 ending=
105 ;;
106
107 o)
108 clock_type=oct
109 ;;
110
111 s)
112 sep=$OPTARG
113 ;;
114
115 u)
116 uppercase=y
117 ;;
118
119 x)
120 clock_type=hex
121 ;;
122
123 z)
124 suppress_seconds=y
125 ;;
126 esac
127done
128
129if [ -z "$clock_type" ]
130then
131 echo "ERROR: must specify clock type"
132 exit 1
133fi
134
135shift $[$OPTIND-1]
136
137# get current time, handling 12-hour or 24-hour
138if [ $format = std ]
139then
140 hrs_format=%l
141else
142 hrs_format=%k
143fi
144
145time=($(date "+${hrs_format} %M %S"))
146h=$(printf ${time[0]})
147m=$(printf ${time[1]})
148s=$(printf ${time[2]})
149
150if [ $clock_type = binary ]
151then
152 [ $suppress_seconds = n ] && seconds="${sep}${binary[10#$s]}"
153 display_time="${binary[10#$h]}${sep}${binary[10#$m]}${seconds}${ending}"
154else
155 if [ $clock_type = hex ]
156 then
157 conversion=x
158 [ $uppercase = y ] && conversion=X
159 else
160 conversion=o
161 fi
162 precision=
163 [ $leading_zeros = y ] && precision=.2
164 base_format=%2${precision}${conversion}
165
166 hh=$(printf "$base_format" $h)
167 hm=$(printf "$base_format" $m)
168 [ "$suppress_seconds" = n ] && hs="${sep}$(printf "$base_format" $s)"
169 display_time="${hh}${sep}${hm}${hs}${ending}"
170fi
171
172echo -ne "$display_time"
173exit 0
0174
=== added file 'usr/lib/byobu/ugraph'
--- usr/lib/byobu/ugraph 1970-01-01 00:00:00 +0000
+++ usr/lib/byobu/ugraph 2011-02-03 23:10:35 +0000
@@ -0,0 +1,212 @@
1#!/bin/bash
2#---------------------------------------------------------------------
3# Script to display a byobo notification "history graph".
4#
5# Designed to work with the wonderful byoby(1) but can be run
6# stand-alone.
7#---------------------------------------------------------------------
8#
9# Copyright (C) 2011 Canonical Ltd.
10#
11# Author: James Hunt <james.hunt@canonical.com>
12#
13# This program is free software: you can redistribute it and/or modify
14# it under the terms of the GNU General Public License as published by
15# the Free Software Foundation, version 3 of the License.
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
27script_name=${0##*/}
28min_default=0
29max_default=100
30points_default=5
31theme_default=vbars_8
32newline="\n"
33rotate=y
34
35error()
36{
37 msg="$*"
38 echo "ERROR: $msg" >&2
39}
40
41die()
42{
43 error "$*"
44 exit 1
45}
46
47usage()
48{
49cat <<EOT
50Description: Display a graph of historical indicator values using
51 ulevel.
52
53Usage: $script_name [options] [command [args...]]
54
55Options:
56
57 -f <file> : File to read data points from.
58 (only required if no command specified).
59 -h : Show this help.
60 -m <num> : Minimum value (default=$min_default).
61 -n : Supress output of newline character.
62 -p <points> : Specify number of data points in graph
63 (default=$points_default).
64 -r : Do not rotate file <file> (default is to rotate).
65 Option implies file <file> should not be written to
66 so a command cannot follow script options in this case.
67 -t <theme> : 'ulevel' theme to use (default=$theme_default).
68 -x <num> : Maximum value (default=$max_default).
69
70
71Examples:
72
73 Using $script_name to run a command, rotate log and display graph.
74
75 Here we specify a command to display available memory.
76 Trailing echo adds a required newline
77 Note no filename specified.
78
79 $script_name "(/usr/lib/byobu/mem_used |sed 's/% //g';echo)"
80
81
82 Using $script_name just to rotate log and display the graph
83
84 file=/tmp/load.dat
85 awk '{ print \$1}' /proc/loadavg >> \$file
86 $script_name -f \$file
87
88Notes:
89
90 - If you specify 'command', care must be taken with shell quoting to
91 avoid expansion prior to this script running the command.
92 - If '-r' is not specified, the file <file> will be rotated such that
93 at most <points> lines are retained on each invocation of this
94 script.
95
96EOT
97}
98
99get_data()
100{
101 needed_lines=$points
102
103 if [ ! -f $file ]
104 then
105 return
106 fi
107
108 lines=$(wc -l $file|awk '{print $1}')
109
110 if [ $lines -lt $needed_lines ]
111 then
112 # insufficient data
113 return
114 fi
115
116 bytes=$(<${file})
117 bytes=$(echo "$bytes"|tail -n ${needed_lines})
118 [ $lines -eq $needed_lines -o $rotate = n ] && echo "$bytes" && return
119
120 # rotate
121 tmp=`tempfile`
122 echo "$bytes" > $tmp
123 mv $tmp $file
124
125 echo "$bytes"
126}
127
128while getopts "f:hm:np:rt:x:" opt
129do
130 case "$opt" in
131 f)
132 file="$OPTARG"
133 ;;
134
135 h)
136 usage
137 exit 0
138 ;;
139
140 m)
141 min=$OPTARG
142 ;;
143
144 n)
145 newline=
146 ;;
147
148 p)
149 points=$OPTARG
150 ;;
151
152 r)
153 rotate=n
154 ;;
155
156 t)
157 theme="$OPTARG"
158 ;;
159
160 x)
161 max=$OPTARG
162 ;;
163 esac
164done
165
166shift $[$OPTIND-1]
167
168cmd="$@"
169
170[ -z "$theme" ] && theme=$theme_default
171
172if [ -z "$cmd" ]
173then
174 if [ -z "$file" ]
175 then
176 error "must specify file"
177 usage
178 exit 1
179 fi
180fi
181
182if [ -z "$file" ]
183then
184 # we could go cryptic+safe by calling tempfile(1), but that then
185 # makes it very difficult to find in case of need.
186 file=/tmp/${USER}-${script_name}-$$.dat
187fi
188
189[ -z "$min" ] && min=$min_default
190[ -z "$max" ] && max=$max_default
191[ -z "$points" ] && points=$points_default
192
193if [ ! -z "$cmd" ]
194then
195 if [ $rotate = n ]
196 then
197 error "cannot write to file if rotate disabled"
198 usage
199 exit 1
200 fi
201
202 eval "$cmd >>$file"
203fi
204
205data=$(get_data)
206
207[ -z "$data" ] && printf "%*.s${newline}" $points && exit 0
208
209for datum in $data
210do
211 ulevel.sh -n -m $min -x $max -c $datum -t $theme
212done
0213
=== added file 'usr/lib/byobu/ulevel'
--- usr/lib/byobu/ulevel 1970-01-01 00:00:00 +0000
+++ usr/lib/byobu/ulevel 2011-02-03 23:10:35 +0000
@@ -0,0 +1,481 @@
1#!/bin/bash
2#---------------------------------------------------------------------
3# Script to display unicode characters representing the level of
4# some indicator.
5#
6# Designed to work with the wonderful byoby(1) but can be run
7# stand-alone.
8#---------------------------------------------------------------------
9#
10# Copyright (C) 2011 Canonical Ltd.
11#
12# Author: James Hunt <james.hunt@canonical.com>
13#
14# This program is free software: you can redistribute it and/or modify
15# it under the terms of the GNU General Public License as published by
16# the Free Software Foundation, version 3 of the License.
17#
18# This program is distributed in the hope that it will be useful,
19# but WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21# GNU General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with this program. If not, see <http://www.gnu.org/licenses/>.
25#
26#---------------------------------------------------------------------
27
28#------------------------------
29# Themes with 2 values.
30#
31# Two-value themes are handled differently to other n-value types of
32# theme: the first array entry in each theme is generally some unfilled
33# glyph, denoting an "off" value and the second value is the filled
34# version of the unfilled glyph and denotes an "on" value. Note that
35# you can always change the ordering of these values using the 'invert'
36# command-line option.
37
38circles_2=(○ ●)
39diamonds_2=(◇ ◆)
40flags_2=(⚐ ⚑)
41hearts_2=(♡ ♥)
42squares_2=(◻ ◼)
43squares_small_2=(◽ ◾)
44stars_2=(☆ ★)
45
46#------------------------------
47# Themes with 4 values.
48
49vdots_thick_4=(⣀ ⣤ ⣶ ⣿)
50vdots_thin_4=(⢀ ⢠ ⢰ ⢸)
51fractions_4=(¼ ½ ¾ ¹)
52quadrants_4=(◔ ◑ ◕ ●)
53shades_4=(░ ▒ ▓ █)
54
55#------------------------------
56# Themes with 5 values.
57
58circles_5=(◦ ○ ◎ ◉ ●)
59
60#------------------------------
61# Themes with 6 values.
62
63dice_6=(⚀ ⚁ ⚂ ⚃ ⚄ ⚅)
64
65#------------------------------
66# Themes with 8 values.
67
68hbars_8=(▏ ▎ ▍ ▌ ▋ ▊ ▉ █)
69vbars_8=(▁ ▂ ▃ ▄ ▅ ▆ ▇ █)
70
71#------------------------------
72# Themes with 10 values.
73
74circle_number_10=(➀ ➁ ➂ ➃ ➄ ➅ ➆ ➇ ➈ ➉)
75solid_numbers_a_10=(➊ ➋ ➌ ➍ ➎ ➏ ➐ ➑ ➒ ➓)
76solid_numbers_b_10=(❶ ❷ ❸ ❹ ❺ ❻ ❼ ❽ ❾ ❿)
77
78#------------------------------
79# XXX: remember to update if you add new themes above!
80
81theme_list=\
82(
83 'circles_2 diamonds_2 flags_2 hearts_2 squares_2 squares_small_2 stars_2'
84 'vdots_thick_4 vdots_thin_4 fractions_4 quadrants_4 shades_4'
85 'circles_5'
86 'dice_6'
87 'hbars_8 vbars_8'
88 'circle_number_10 solid_numbers_a_10 solid_numbers_b_10'
89)
90
91#------------------------------
92
93debug_enabled=n
94newline=
95list=n
96quiet=n
97invert=n
98reverse=n
99script_name=${0##*/}
100min_default=0
101max_default=100
102width_default=5
103zero_as_space=n
104theme_default=vbars_8
105
106debug()
107{
108 msg="$*"
109 [ $debug_enabled = y ] && echo "DEBUG: $msg"
110}
111
112error()
113{
114 msg="$*"
115 echo "ERROR: $msg" >&2
116}
117
118die()
119{
120 error "$*"
121 exit 1
122}
123
124bc_test()
125{
126 expr="$*"
127 echo $(echo "if ( $expr ) { print \"1\" }"|bc -l)
128}
129
130assert()
131{
132 expr="$1"
133 str="$2"
134
135 debug "assert: expr='$expr'"
136 ret=$(bc_test "$expr")
137
138 [ ! -z "$ret" ] && return
139
140 die "$str"
141}
142
143usage()
144{
145cat <<EOT
146Description: Display unicode characters representing the relative
147 level of some indicator value within a range.
148
149Usage: $script_name [options] -c <current_num>
150 $script_name [options] <current_num>
151 $script_name <current_num>
152
153Options:
154
155 -b : Display current value as space if zero, rather than lowest
156 'value' of theme.
157 -c <num> : Current value of your indicator.
158 -d : Enable debug output.
159 -h : Show this help.
160 -i : Invert colour scheme (rating themes only).
161 -l : List available themes. If '-t' also specified,
162 show all values for specified theme.
163 -m <num> : Minimum value (default=$min_default).
164 -n : Supress output of newline character.
165 -q : Suppress messages (requires '-t').
166 -r : Reverse 'direction' of display (rating theme only).
167 -t <theme> : Name of theme (default=$theme_default).
168 -u <chars> : Specify a user theme (2 or more values).
169 -w <int> : Width of rating theme (default=$width_default).
170 -x <num> : Maximum value (default=$max_default).
171
172
173Examples:
174
175 # Display character representing 27% using default theme.
176 $script_name 27
177
178 # As above.
179 $script_name -c 27
180
181 # Example showing floating-point and negative values.
182 $script_name -c 1.100001 -m -5.00234 -x 2.71828 -t dice_6
183
184 # Display value using a "rating theme" (displayed left-to-right).
185 $script_name -c 83 -t stars_2
186
187 # Display right-to-left inverted "rating theme".
188 $script_name -c 60 -t diamonds_2 -ri
189
190 # Display all glyphs in 'solid_numbers_a_10' theme.
191 $script_name -l -t solid_numbers_a_10
192
193 # Display a user-specified rating theme 10 glyphs wide.
194 $script_name -c 666.321 -m -273.15 -x 1370 -u "· ☢" -w 10
195
196 # A multi-element user theme (this prints 'e').
197 $script_name -c 50 -u "a b c d e f g h i j"
198
199
200Notes:
201
202 - Arguments of type "<int>" denote an integer value, whereas arguments
203 of type "<num>" denotes either an integer or a floating-point
204 number.
205 - The final '_<number>' in a theme name denotes the number of glyphs
206 in it.
207 - "Rating themes" are those with only 2 values.
208 - The <chars> argument to '-u' must contain space-delimited
209 characters.
210
211EOT
212}
213
214# this is horribly inefficient - we should probably do some clever
215# tricks using printf formats to avoid the silly while loop.
216# Additionally, it is rather similar to show_theme_entry() but was split
217# out from that in a vain attempt to make the overall logic clearer :)
218show_rating_theme()
219{
220 theme="$1"
221 min="$2"
222 max="$3"
223 current="$4"
224 quotient="$5"
225
226 if [ $invert = n ]
227 then
228 on=1
229 off=0
230 else
231 on=0
232 off=1
233 fi
234
235 percent=$(echo "$quotient * 100"|bc -l)
236 debug "width=$width"
237 debug "percent=$percent"
238
239 percent_per_glyph=$(echo "scale=4;100/${width}"|bc -l)
240 assert "$percent_per_glyph > 1.0" "width ($width) too great"
241 debug "percent_per_glyph=$percent_per_glyph"
242
243 debug "glyph_count=$glyph_count"
244
245 g=$percent_per_glyph
246 i=0
247 value=""
248 while [ $i -lt $width ]
249 do
250 if [ ! -z "$(bc_test "$g <= $percent")" ]
251 then
252 eval content="\${$theme[${on}]}"
253 else
254 eval content="\${$theme[${off}]}"
255 fi
256 if [ $reverse = n ]
257 then
258 value="${value}${content}"
259 else
260 value="${content}${value}"
261 fi
262 g=$(echo "$g + $percent_per_glyph"|bc -l)
263 i=$((i + 1))
264 done
265 echo $newline "$value"
266}
267
268show_theme_entry()
269{
270 theme="$1"
271 min="$2"
272 max="$3"
273 current="$4"
274
275 debug "theme=$theme"
276 debug "min=$min"
277 debug "max=$max"
278 debug "current=$current"
279
280 range=$(echo "($max - $min)"|bc -l)
281
282 quotient=$(echo "scale=4;((${current} - ${min})/${range})"|bc -l)
283
284 glyph_count=$(echo $theme|awk -F\_ '{print $NF}')
285
286 debug "range=$range"
287 debug "quotient=$quotient"
288 debug "glyph_count=$glyph_count"
289
290 if [ $glyph_count -eq 2 ]
291 then
292 show_rating_theme "$theme" "$min" "$max" "$current" "$quotient"
293 return
294 fi
295
296 percent_per_glyph=$(echo "100/$glyph_count"|bc -l)
297 debug "percent_per_glyph=$percent_per_glyph"
298
299 assert "$percent_per_glyph > 1.0" "width ($width) too great"
300
301 # with this scheme, assuming current value is 0-100 and theme has 10
302 # elements:
303 #
304 # current glyph from theme
305 #
306 # 0-19 1st
307 # 20-29 2nd
308 # 30-39 3rd
309 # :
310 # 90-99 9th
311 # 100 10th
312 i=$(echo|awk \
313 -v quotient=$quotient \
314 -v glyph_count=$glyph_count \
315 '{
316 x= int( (quotient * glyph_count) ) - 1;
317 x = (x > (glyph_count-1) ? (glyph_count-1) : x);
318 if ( x < 0 ) x = 0;
319 printf("%d", x);
320 }')
321
322 debug "index=$i"
323 eval content="\${$theme[$i]}"
324
325 [ ! -z "$(bc_test "$current == 0")" -a $zero_as_space = y ] && content=' '
326 echo $newline "$content"
327
328 return
329}
330
331list_theme()
332{
333 theme="$1"
334 eval content="\${$theme[@]}"
335 echo
336 for c in $content
337 do
338 echo -n "$c "
339 done
340 echo -e "\n"
341}
342
343list_themes()
344{
345 for entry in ${theme_list[@]}
346 do
347 for arg in "$entry"
348 do
349 echo "$arg"
350 done
351 done
352}
353
354theme_valid()
355{
356 theme="$1"
357 [ -z "`list_themes|grep "^${theme}$"`" ] && return 1
358 return 0
359}
360
361# XXX: the seemingly pointless 'tr' calls translate unicode dashes (look
362# closely!) into ASCII dashes. This is required since 'bc' borks on
363# unicode and it is easy to mistakenly pass unicode dashes if you paste
364# characters from another application, such as a web-browser.
365while getopts "bc:dhilm:nqrt:u:w:x:" opt
366do
367 case "$opt" in
368 b)
369 zero_as_space=y
370 ;;
371
372 c)
373 current=$(echo $OPTARG|tr '−' '-')
374 ;;
375
376 d)
377 debug_enabled=y
378 ;;
379
380 h)
381 usage
382 exit 0
383 ;;
384
385 i)
386 invert=y
387 ;;
388
389 l)
390 list=y
391 ;;
392
393 m)
394 min=$(echo $OPTARG|tr '−' '-')
395 ;;
396
397 n)
398 newline=-n
399 ;;
400
401 q)
402 quiet=y
403 ;;
404
405 r)
406 reverse=y
407 ;;
408
409 t)
410 theme=$OPTARG
411 ;;
412
413 u)
414 user_theme="$OPTARG"
415 ;;
416
417 w)
418 width=$OPTARG
419 ;;
420
421 x)
422 max=$(echo $OPTARG|tr '−' '-')
423 ;;
424 esac
425done
426
427shift $[$OPTIND-1]
428
429if [ ! -z "$user_theme" ]
430then
431 elements=$(echo "$user_theme"|awk '{print NF}')
432
433 assert "$elements >= 2" "user themes need >= 2 values"
434
435 # create new theme
436 name="_user_${elements}"
437 eval "$name=($user_theme)"
438
439 # add it to list
440 theme_list=("${theme_list[@]}" $name)
441
442 [ -z "$theme" ] && theme=$name
443fi
444
445if [ "$list" = y ]
446then
447 if [ -z "$theme" ]
448 then
449 list_themes && exit 0
450 else
451 theme_valid "$theme" || die "invalid theme: $theme"
452 [ "$quiet" = n ] && echo "Listing theme '$theme'"
453 list_theme $theme && exit 0
454 fi
455fi
456[ -z "$min" ] && min=$min_default
457[ -z "$max" ] && max=$max_default
458[ -z "$width" ] && width=$width_default
459
460assert "$min <= $max" "minimum ($min) > maximum ($max)"
461assert "$min != $max" "minimum ($min) == maximum"
462
463[ -z "$current" -a ! -z "$1" ] && current="$1"
464
465if [ -z "$current" ]
466then
467 error "must specify current value"
468 usage
469 exit 1
470fi
471
472assert "$current >= $min" "current ($current) < minimum ($min)"
473assert "$current <= $max" "current ($current) > maximum ($max)"
474
475[ -z "$theme" ] && theme=$theme_default
476
477theme_valid "$theme" || die "invalid theme: $theme"
478
479show_theme_entry $theme $min $max $current
480
481exit 0
0482
=== added file 'usr/lib/byobu/wastebasket'
--- usr/lib/byobu/wastebasket 1970-01-01 00:00:00 +0000
+++ usr/lib/byobu/wastebasket 2011-02-03 23:10:35 +0000
@@ -0,0 +1,39 @@
1#!/bin/sh -e
2#
3# wastebasket: show icon (and optionally count) if entries in wastebasket.
4# Copyright (C) 2011 Canonical Ltd.
5#
6# Authors: James Hunt <james.hunt@canonical.com>
7
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, version 3 of the License.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20
21PKG="byobu"
22color 2>/dev/null || color() { true; }
23
24[ "$UTF8" = "1" ] && ICON="♸" || ICON="W"
25
26dir=$HOME/.local/share/Trash/files
27
28[ ! -d $dir ] && exit 0
29count=$(ls $dir|wc -l)
30[ "$count" -eq 0 ] && exit 0
31
32if [ "$1" = "--detail" ]
33then
34 echo -n "${ICON}[$count]"
35else
36 echo -n $ICON
37fi
38
39exit 0
040
=== modified file 'usr/lib/byobu/wifi_quality'
--- usr/lib/byobu/wifi_quality 2011-01-31 23:19:40 +0000
+++ usr/lib/byobu/wifi_quality 2011-02-03 23:10:35 +0000
@@ -19,6 +19,7 @@
1919
20PKG="byobu"20PKG="byobu"
21color 2>/dev/null || color() { true; }21color 2>/dev/null || color() { true; }
22[ "$UTF8" = "1" ] && ICON="⚚" || ICON=
2223
23if [ "$1" = "--detail" ]; then24if [ "$1" = "--detail" ]; then
24 /sbin/iwconfig 2>/dev/null25 /sbin/iwconfig 2>/dev/null
@@ -35,4 +36,4 @@
35 quality=`echo "$quality" | awk -F/ '{printf "%.0f", 100*$1/$2}'`36 quality=`echo "$quality" | awk -F/ '{printf "%.0f", 100*$1/$2}'`
36fi37fi
37[ "$quality" = "0" ] && exit 038[ "$quality" = "0" ] && exit 0
38printf "$(color b C k)%s$(color -)$(color C k)%s,$(color -)$(color b C k)%s$(color -)$(color C k)%%$(color -) " "$bitrate" "Mbps" "$quality"39printf "${ICON}$(color b C k)%s$(color -)$(color C k)%s,$(color -)$(color b C k)%s$(color -)$(color C k)%%$(color -) " "$bitrate" "Mbps" "$quality"

Subscribers

People subscribed via source and target branches