~ubuntu-branches/ubuntu/utopic/byobu/utopic

« back to all changes in this revision

Viewing changes to bin/uptime

  • Committer: Bazaar Package Importer
  • Author(s): Dustin Kirkland
  • Date: 2010-01-11 22:54:36 UTC
  • mto: This revision was merged to the branch mainline in revision 49.
  • Revision ID: james.westby@ubuntu.com-20100111225436-csnrc41k0bewth1e
Tags: upstream-2.47
Import upstream version 2.47

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh -e
2
 
#
3
 
#  uptime: condensed uptime of the machine
4
 
#  Copyright (C) 2009 Raphaël Pinson.
5
 
#  Copyright (C) 2009 Canonical Ltd.
6
 
#
7
 
#  Authors: Raphaël Pinson <raphink@ubuntu.com>
8
 
#           Dustin Kirkland <kirkland@canonical.com>
9
 
#
10
 
#  This program is free software: you can redistribute it and/or modify
11
 
#  it under the terms of the GNU General Public License as published by
12
 
#  the Free Software Foundation, version 3 of the License.
13
 
#
14
 
#  This program is distributed in the hope that it will be useful,
15
 
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
#  GNU General Public License for more details.
18
 
#
19
 
#  You should have received a copy of the GNU General Public License
20
 
#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 
#
22
 
 
23
 
PKG="byobu"
24
 
color 2>/dev/null || color() { true; }
25
 
 
26
 
if [ "$1" = "--detail" ]; then
27
 
        uptime
28
 
        exit 0
29
 
fi
30
 
 
31
 
u=$(sed "s/\..*$//" /proc/uptime)
32
 
printf "$(color w b)"
33
 
if [ "$u" -gt 86400 ]; then
34
 
        echo "$u" | awk '{printf "%dd%dh", $1 / 86400, ($1 % 86400)/3600 }'
35
 
elif [ "$u" -gt 3600 ]; then
36
 
        echo "$u" | awk '{printf "%dh%dm", $1 / 3600, ($1 % 3600 )/60}'
37
 
elif [ "$u" -gt 60 ]; then
38
 
        echo "$u" | awk '{printf "%dm", $1 / 60 }'
39
 
else
40
 
        printf "%ds" "$u"
41
 
fi
42
 
printf "$(color -) "