From 36f3a4c6febdf4e2ce8e1c328de88bac20f64f63 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Fri, 19 Jun 2009 16:19:46 -0500 Subject: [PATCH] * byobu-status, byobu-export, debian/install: source default status states, rather than the big case statement, performance improvement for all status, also reduces the number of places to touch when a new status script is added Signed-off-by: Dustin Kirkland --- byobu-export | 18 +--------- byobu-status | 85 ++++++++++++++---------------------------------- debian/changelog | 6 +++- debian/install | 1 + 4 files changed, 32 insertions(+), 78 deletions(-) diff --git a/byobu-export b/byobu-export index 1092169c..b964f9aa 100755 --- a/byobu-export +++ b/byobu-export @@ -85,22 +85,6 @@ choose() { exit 1 } -status_config() { - # Generate the status configuration - # Disable the menu, since configurator is not available - # Enable user@host in its place - for i in $(ls /usr/lib/$PKG/); do - case "$i" in - cpu_count|cpu_freq|date|hostname|load_average|logo|mem_available|mem_used|reboot_required|release|time|updates_available|whoami) - echo "$i=1" - ;; - *) - echo "$i=0" - ;; - esac - done -} - hr() { echo "###############################################################################" } @@ -233,7 +217,7 @@ cp -a /usr/bin/$PKG-status "$DIR/.$PKG" # Generate the monolithic profile header > "$PROFILE" sources >> "$PROFILE" -status_config > "$STATUS" +cp /etc/$PKG/statusrc > "$STATUS" # Some gardening # Drop additional "source" calls diff --git a/byobu-status b/byobu-status index c392f82e..6e164217 100755 --- a/byobu-status +++ b/byobu-status @@ -17,15 +17,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -########################################################### -# We should be really "nice" about gathering status: -#renice 10 $$ >/dev/null 2>&1 || true -#ionice -c3 -p $$ >/dev/null 2>&1 || true -# However, this *really* slows down startup. -# We need a good way of only doing this for updates, -# but not at screen startup. -########################################################### - PKG="byobu" migrate() { @@ -44,60 +35,34 @@ migrate() { fi } -# If the old config dir exists, but the new one doesn't, provide a migration mechanism -[ -d "$HOME/.$OLDPKG" -a ! -d "$HOME/.$PKG" ] && migrate +# If the old config dir exists, but the new one doesn't, provide a migration mechanism. +[ -d "$HOME/.$OLDPKG"] && [ ! -d "$HOME/.$PKG" ] && migrate # Allow for local status scripts -if [ -d "$HOME/.$PKG/bin" ]; then - DIR="$HOME/.$PKG/bin" -elif [ -d "/usr/lib/$PKG" ]; then - DIR="/usr/lib/$PKG" -else - exit 1 -fi +DIR="/usr/lib/$PKG" +[ -d "$HOME/.$PKG/bin" ] && DIR="$HOME/.$PKG/bin" -# Source status file -if [ -r "$HOME/.$PKG/status" ]; then - if ! . "$HOME/.$PKG/status" ; then - # If sourcing fails, try replacing - with _ - sed -i "s/-/_/g" "$HOME/.$PKG/status" +# Source global status configuration +. "/etc/$PKG/statusrc" || true +# Source local status configuration +. "$HOME/.$PKG/status" || sed -i "s/-/_/g" "$HOME/.$PKG/status" || true + +export P="$1" +if [ "$P" = "--detail" ]; then + VER= + if which dpkg-query >/dev/null; then + VER=`dpkg-query --show $PKG | awk '{print "-" $2 }'` fi -fi - -P="$1" -case "$P" in - # default = on, user must override to turn off - cpu_count|cpu_freq|date|load_average|logo|mem_available|mem_used|menu|reboot_required|release|time|updates_available|uptime) - eval x=\$$P - export $P - [ "$x" = "0" ] && exit 0 - ;; - # default = off, user must override to turn on - arch|battery|disk|ec2_cost|hostname|ip_address|mail|network|processes|users|temp_c|temp_f|whoami|wifi_quality) - eval x=\$$P - export $P + printf "$PKG$VER Detailed Status Navigation\n Expand all - zr\t\tCollapse all - zm\n Expand one - zo\t\tCollapse one - zc\n\n" + for i in `ls "$DIR"`; do + [ "$i" = "menu" ] && continue + short=`"$DIR"/$i --short | sed 's/^\s*//' | sed 's/\s*$//' | sed 's/.{[^}]*}//g'` || true + detail=`"$DIR"/$i --detail | sed '/^$/d' | sed 's/^/\t/g'` || true + printf "%s\n\t(%s)\n" "$short" "$i" + [ -n "$detail" ] && printf "%s\n" "$detail" + done +else + eval x=\$$P || exit 1 [ "$x" = "1" ] || exit 0 - ;; - --detail) - VER= - if which dpkg-query >/dev/null; then - VER=`dpkg-query --show $PKG | awk '{print "-" $2 }'` - fi - printf "$PKG$VER Detailed Status Navigation\n Expand all - zr\t\tCollapse all - zm\n Expand one - zo\t\tCollapse one - zc\n\n" - for i in `ls "$DIR"`; do - [ "$i" = "menu" ] && continue - short=`"$DIR"/$i --short | sed 's/^\s*//' | sed 's/\s*$//' | sed 's/.{[^}]*}//g'` || true - detail=`"$DIR"/$i --detail | sed '/^$/d' | sed 's/^/\t/g'` || true - printf "%s\n\t(%s)\n" "$short" "$i" - [ -n "$detail" ] && printf "%s\n" "$detail" - done - exit 0 - ;; - *) - exit 1 - ;; -esac - -if [ -f "$DIR"/"$P" -a -x "$DIR"/"$P" ]; then - exec "$DIR"/"$P" + [ -x "$DIR"/"$P" ] exec "$DIR"/"$P" fi diff --git a/debian/changelog b/debian/changelog index 7eae3b83..c699ea74 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,11 +6,15 @@ byobu (2.13) unreleased; urgency=low screen-launcher * byobu-config: improve the verbage of some of the menus, per review with the Canonical Design Team + * byobu-status, byobu-export, debian/install: source default status + states, rather than the big case statement, performance improvement + for all status, also reduces the number of places to touch when a + new status script is added [ Ciemon Dunville ] * byobu.1: reflect the keybinding toggle change to Ctrl-a-! - -- Dustin Kirkland Fri, 19 Jun 2009 14:59:28 -0500 + -- Dustin Kirkland Fri, 19 Jun 2009 16:18:53 -0500 byobu (2.12-0ubuntu1) karmic; urgency=low diff --git a/debian/install b/debian/install index a36c2801..a12036fc 100644 --- a/debian/install +++ b/debian/install @@ -7,6 +7,7 @@ profiles/black usr/share/byobu/profiles profiles/dark usr/share/byobu/profiles profiles/light usr/share/byobu/profiles keybindings/* usr/share/byobu/keybindings +statusrc etc/byobu windows/common usr/share/byobu/windows select-screen-profile usr/bin byobu usr/bin