From a47cf85f242540cb5a7a89a086696d718e455f17 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Thu, 7 May 2009 00:55:40 -0500 Subject: [PATCH] * bin/disk-available, bin/disk-used, byobu-config, byobu-config.1, byobu-status, profiles/common, profiles/profile.skel: add a new pair of status notifications for disk space available and used; default to / directory, allow user override in config dir Signed-off-by: Dustin Kirkland --- bin/disk-available | 39 +++++++++++++++++++++++++++++++++++++++ bin/disk-used | 36 ++++++++++++++++++++++++++++++++++++ byobu-config | 2 ++ byobu-config.1 | 4 ++++ byobu-status | 2 +- debian/changelog | 6 +++++- profiles/common | 2 ++ profiles/profile.skel | 2 +- 8 files changed, 90 insertions(+), 3 deletions(-) create mode 100755 bin/disk-available create mode 100755 bin/disk-used diff --git a/bin/disk-available b/bin/disk-available new file mode 100755 index 00000000..e9ead3e3 --- /dev/null +++ b/bin/disk-available @@ -0,0 +1,39 @@ +#!/bin/sh -e +# +# disk-available: print the current disk space available +# Copyright (C) 2008 Canonical Ltd. +# +# Authors: Dustin Kirkland +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +PKG="byobu" + +if [ "$1" = "--detail" ]; then + df -h + exit 0 +fi + +comma= +whitespace= +if [ -r "$HOME/.$PKG/status" ]; then + grep -qs "^disk-used=1$" "$HOME/.$PKG/status" && comma="," || whitespace=" " +else + comma="," +fi + +# Default to /, but let users override +[ -r "$HOME/.$PKG/disk" ] && MP=`cat "$HOME/.$PKG/disk"` || MP="/" + +d=`df -h "$MP" | tail -n 1 | awk '{print $2}'` +printf "\005{= MW}%sB%s\005{-}%s" "$d" "$comma" "$whitespace" diff --git a/bin/disk-used b/bin/disk-used new file mode 100755 index 00000000..65987790 --- /dev/null +++ b/bin/disk-used @@ -0,0 +1,36 @@ +#!/bin/sh -e +# +# disk-used: print the current disk usage +# Copyright (C) 2008 Canonical Ltd. +# +# Authors: Dustin Kirkland +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +PKG="byobu" + +if [ "$1" = "--detail" ]; then + df -h + exit 0 +fi + +whitespace= +if [ -r "$HOME/.$PKG/status" ]; then + grep -qs "^date=1$" "$HOME/.$PKG/status" && whitespace=" " +fi + +# Default to /, but let users override +[ -r "$HOME/.$PKG/disk" ] && MP=`cat "$HOME/.$PKG/disk"` || MP="/" + +df -h "$MP" | tail -n 1 | awk '{print "\005{= MW}" $5 "\005{-}"}' +printf "%s" "$whitespace" diff --git a/byobu-config b/byobu-config index cb2ac57c..24e74b76 100755 --- a/byobu-config +++ b/byobu-config @@ -249,6 +249,8 @@ def readstatus(): status["cpu-count"]=1 status["cpu-freq"]=1 status["date"]=1 + status["disk-available"]=0 + status["disk-used"]=0 status["ec2-cost"]=0 status["hostname"]=0 status["ip-address"]=0 diff --git a/byobu-config.1 b/byobu-config.1 index 7c423b9e..326097fe 100644 --- a/byobu-config.1 +++ b/byobu-config.1 @@ -21,6 +21,10 @@ The menu provided by the \fBbyobu\fP should be self-explanatory. \fBdate\fP \- the system date in YYYY-MM-DD formate; displayed in the lower on the far right in the default text color on the default background +\fBdisk-available\fP \- disk space available on / directory; displayed in the lower bar on the far right in white text on a light purple background; override the default directory by specifying an alternate mount point in \fI$HOME/.byobu/disk\fP + +\fBmem-used\fP \- disk space used on / directory as a percentage of the total space available on /; displayed in the lower bar on the far right in white text on a light purple background with a trailing '%' sign; override the default directory by specifying an alternate mount point in \fI$HOME/.byobu/disk\fP + \fBec2-cost\fP \- an estimation of the cost of the current boot of the system in terms of the Amazon EC2 billing model; displayed in the lower bar toward the right in green text on a grey background; there is a leading '~' to indicate that this is an estimation, and the monetary units are US Dollars '$' \fBhostname\fP \- the hostname of the system; displayed in the upper bar on the far right in bold black text on a grey background; there is a leading '@' symbol if the username status is also enabled diff --git a/byobu-status b/byobu-status index 1493757c..8b7557b3 100755 --- a/byobu-status +++ b/byobu-status @@ -63,7 +63,7 @@ case "$P" in grep -qs -m1 "^$P=0$" "$HOME/.$PKG/status" && exit 0 ;; # default = off, user must override to turn on - arch|battery|ec2-cost|hostname|ip-address|network-down|network-up|processes|users|whoami|wifi-quality) + arch|battery|disk-available|disk-used|ec2-cost|hostname|ip-address|network-down|network-up|processes|users|whoami|wifi-quality) grep -qs -m1 "^$P=1$" "$HOME/.$PKG/status" || exit 0 ;; --detail) diff --git a/debian/changelog b/debian/changelog index 4cee3746..6f0f7082 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,10 @@ byobu (2.1) unreleased; urgency=low * byobu-status, debian/rules: migrate existing screen-profiles config dir smoothly by linking the old screen-profiles-status script to the new byobu-status, and add a migrate function to that script + * bin/disk-available, bin/disk-used, byobu-config, byobu-config.1, + byobu-status, profiles/common, profiles/profile.skel: add a new + pair of status notifications for disk space available and used; + default to / directory, allow user override in config dir Tranform byobu-status --detail to use vim's folding feature * byobu-status: output text compatible with vim's folding feature @@ -26,7 +30,7 @@ byobu (2.1) unreleased; urgency=low * bin/users: grep out the grep statement in the ps * bin/whoami: print /etc/passwd info on --detail - -- Dustin Kirkland Thu, 07 May 2009 00:25:39 -0500 + -- Dustin Kirkland Thu, 07 May 2009 00:54:43 -0500 byobu (2.0-0ubuntu1) karmic; urgency=low diff --git a/profiles/common b/profiles/common index f569d52c..bf9f03eb 100644 --- a/profiles/common +++ b/profiles/common @@ -50,6 +50,8 @@ backtick 119 2 2 byobu-status wifi-quality backtick 120 86400 86400 byobu-status date backtick 121 86400 86400 byobu-status time backtick 122 3600 3600 byobu-status ip-address +backtick 123 86400 86400 byobu-status disk-available +backtick 124 2 2 byobu-status disk-used hardstatus alwayslastline diff --git a/profiles/profile.skel b/profiles/profile.skel index 1d1682ae..7ff320b0 100644 --- a/profiles/profile.skel +++ b/profiles/profile.skel @@ -26,7 +26,7 @@ source /usr/share/byobu/profiles/common caption always "%{kW}%?%-Lw%?%{bw}%n*%f %t%?(%u)%?%{kW}%?%+Lw%? %= %{= Wk}%110`%109`%122`%111`" # Status string, last line -hardstatus string '%99`%{= Wk} %100`%112`%= %102`%101`%114`%115`%108`%113`%119`%117`%118`%116`%106`%104`%103`%105`%107`%120`%121`' +hardstatus string '%99`%{= Wk} %100`%112`%= %102`%101`%114`%115`%108`%113`%119`%117`%118`%116`%106`%104`%103`%105`%107`%123`%124`%120`%121`' # NOTE: Older version of screen have an arbitrary limit of only being able # to change colors 16 times in this 'hardstatus string'.