~ubuntu-branches/ubuntu/precise/byobu/precise

« back to all changes in this revision

Viewing changes to byobu-status

  • Committer: Bazaar Package Importer
  • Author(s): Dustin Kirkland
  • Date: 2009-05-07 00:54:43 UTC
  • Revision ID: james.westby@ubuntu.com-20090507005443-6ryuqfkl4vphssnw
Tags: upstream-2.1
ImportĀ upstreamĀ versionĀ 2.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh -e
 
2
#
 
3
#    byobu-status
 
4
#    Copyright (C) 2008 Canonical Ltd.
 
5
#
 
6
#    Authors: Dustin Kirkland <kirkland@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
###########################################################
 
21
# We should be really "nice" about gathering status:
 
22
#renice 10 $$ >/dev/null 2>&1 || true
 
23
#ionice -c3 -p $$ >/dev/null 2>&1 || true
 
24
# However, this *really* slows down startup.
 
25
# We need a good way of only doing this for updates,
 
26
# but not at screen startup.
 
27
###########################################################
 
28
 
 
29
PKG="byobu"
 
30
 
 
31
if [ -d "$HOME/.$PKG/bin" ]; then
 
32
        DIR="$HOME/.$PKG/bin"
 
33
elif [ -d "/usr/lib/$PKG" ]; then
 
34
        DIR="/usr/lib/$PKG"
 
35
else
 
36
        exit 1
 
37
fi
 
38
 
 
39
P="$1"
 
40
B='\033[34;1m'
 
41
W='\033[47m'
 
42
X='\033[0m'
 
43
HR="                                                                               "
 
44
 
 
45
case "$P" in
 
46
        # default = on, user must override to turn off
 
47
        cpu-count|cpu-freq|date|load-average|logo|mem-available|mem-used|menu|reboot-required|release|time|updates-available|uptime)
 
48
                grep -qs -m1 "^$P=0$" "$HOME/.$PKG/status" && exit 0
 
49
        ;;
 
50
        # default = off, user must override to turn on
 
51
        arch|battery|ec2-cost|hostname|ip-address|network-down|network-up|processes|users|whoami|wifi-quality)
 
52
                grep -qs -m1 "^$P=1$" "$HOME/.$PKG/status" || exit 0
 
53
        ;;
 
54
        --detail)
 
55
                printf "\033[1m"
 
56
                [ -x "/usr/bin/dpkg-query" ] && /usr/bin/dpkg-query --show $PKG | awk '{print "# $PKG (" $2 ") detailed status:"}'
 
57
                printf "$X\n"
 
58
                for i in `ls "$DIR"`; do
 
59
                        [ "$i" = "menu" ] && continue
 
60
                        printf "\n$W%s$X\n" "$HR"
 
61
                        printf "$W $X $B# %s:$X\n" "$i"
 
62
                        out=`"$DIR"/$i --detail | sed 's/^/\\\033[47m \\\033[0m    /g'` || true
 
63
                        printf "$out\n"
 
64
                        printf "$W%s$X\n\n" "$HR"
 
65
                done
 
66
                exit 0
 
67
        ;;
 
68
        *)
 
69
                exit 1
 
70
        ;;
 
71
esac
 
72
 
 
73
if [ -f "$DIR"/"$P" -a -x "$DIR"/"$P" ]; then
 
74
        exec "$DIR"/"$P"
 
75
fi