diff --git a/debian/changelog b/debian/changelog index c1dd062a..4b9e90e9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -29,6 +29,11 @@ byobu (4.30) unreleased; urgency=low - fix default status * usr/share/byobu/profiles/common, usr/share/byobu/profiles/tmux: - drop backticks and double printing of date/time in tmux + * usr/bin/byobu-status, usr/bin/byobu-status-tmux => usr/bin/byobu- + status, usr/bin/Makefile.am, usr/share/byobu/profiles/common, + usr/share/byobu/profiles/tmux, usr/share/man/man1/byobu-status.1: + - transition to the new, faster, less-resource intensive status + gathering method -- Dustin Kirkland Thu, 11 Aug 2011 10:31:31 -0500 diff --git a/usr/bin/Makefile.am b/usr/bin/Makefile.am index a2d8f90b..3a4ceb15 100644 --- a/usr/bin/Makefile.am +++ b/usr/bin/Makefile.am @@ -1,2 +1,2 @@ -bin_SCRIPTS = byobu byobu-config byobu-ctrl-a byobu-disable byobu-enable byobu-export byobu-janitor byobu-launch byobu-launcher byobu-launcher-install byobu-launcher-uninstall byobu-quiet byobu-reconnect-sockets byobu-select-profile byobu-select-session byobu-silent byobu-status byobu-status-tmux byobu-status-detail byobu-shell +bin_SCRIPTS = byobu byobu-config byobu-ctrl-a byobu-disable byobu-enable byobu-export byobu-janitor byobu-launch byobu-launcher byobu-launcher-install byobu-launcher-uninstall byobu-quiet byobu-reconnect-sockets byobu-select-profile byobu-select-session byobu-silent byobu-status byobu-status-detail byobu-shell diff --git a/usr/bin/byobu-status b/usr/bin/byobu-status index cd1d5034..09531612 100755 --- a/usr/bin/byobu-status +++ b/usr/bin/byobu-status @@ -1,7 +1,8 @@ -#!/bin/sh -e +#!/bin/sh # -# byobu-status -# Copyright (C) 2008 Canonical Ltd. +# byobu-status: byobu's cached status gathering +# +# Copyright (C) 2011 Dustin Kirkland # # Authors: Dustin Kirkland # @@ -21,15 +22,44 @@ PKG="byobu" [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/.common" +# Make sure status is not disabled [ -f "$BYOBU_CONFIG_DIR/status.disable" ] && exit 0 +# Clean and create cache directories +mkdir -p "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND" "$BYOBU_RUN_DIR/.last.$BYOBU_BACKEND" + # Source configurations for i in "${BYOBU_PREFIX}/share/$PKG/status/status" "${BYOBU_PREFIX}/share/$PKG/status/statusrc" "$BYOBU_CONFIG_DIR/status" "$BYOBU_CONFIG_DIR/statusrc" "$BYOBU_CONFIG_DIR/color"; do [ -r "$i" ] && . "$i" done -export P="$1" -case "$P" in +# Get the current timestamp +get_now; NOW=${_RET} + +get_status() { + local cachepath="$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/$1" + local lastpath="$BYOBU_RUN_DIR/.last.$BYOBU_BACKEND/$1" + local lastrun + [ -r "$lastpath" ] && read lastrun < "$lastpath" || lastrun=0 + status_freq "$1" + local expiry=$(($lastrun+$_RET)) + find_script "$1" && . "${_RET}" + # Update cache now, if necessary + if [ $NOW -ge $expiry ] || [ "$lastrun" = "0" ]; then + "__$1" > "$cachepath" + echo "$NOW" > "$lastpath" + fi + IFS= read line < "$cachepath"; printf "$line" +} + +case "$1" in + *left|*right) + eval items="\$$1" + for i in $items; do + case "$i" in \#*) continue ;; esac + get_status "$i" + done + ;; --detail) VER= if command -v dpkg-query >/dev/null; then @@ -56,13 +86,4 @@ case "$P" in [ -z "$BACKGROUND" ] && BACKGROUND="k" printf "$ESC{= $BACKGROUND$FOREGROUND}" ;; - *) - eval x="\$$P" || exit 1 - [ "$x" = "1" ] || exit 0 - shift - find_script "$P" && . "${_RET}" - eval "__${P}" - ;; esac - -# vi: syntax=sh ts=4 noexpandtab diff --git a/usr/bin/byobu-status-tmux b/usr/bin/byobu-status-tmux deleted file mode 100755 index 6a55b2e5..00000000 --- a/usr/bin/byobu-status-tmux +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh -# -# byobu-status-tmux: byobu's status gathering for tmux -# -# Copyright (C) 2011 Dustin Kirkland -# -# 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" -[ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX -. "${BYOBU_PREFIX}/lib/${PKG}/.common" - -# Make sure status is not disabled -[ -f "$BYOBU_CONFIG_DIR/status.disable" ] && exit 0 - -# Clean and create cache directories -mkdir -p "$BYOBU_RUN_DIR/status.$BYOBU_BACKEND" "$BYOBU_RUN_DIR/.last.$BYOBU_BACKEND" - -# Source configurations -for i in "${BYOBU_PREFIX}/share/$PKG/status/status" "${BYOBU_PREFIX}/share/$PKG/status/statusrc" "$BYOBU_CONFIG_DIR/status" "$BYOBU_CONFIG_DIR/statusrc" "$BYOBU_CONFIG_DIR/color"; do - [ -r "$i" ] && . "$i" -done - -# Get the current timestamp -get_now; NOW=${_RET} - -get_status() { - local cachepath="$BYOBU_RUN_DIR/status.$BYOBU_BACKEND/$1" - local lastpath="$BYOBU_RUN_DIR/.last.$BYOBU_BACKEND/$1" - local lastrun - [ -r "$lastpath" ] && read lastrun < "$lastpath" || lastrun=0 - status_freq "$1" - local expiry=$(($lastrun+$_RET)) - find_script "$1" && . "${_RET}" - # Update cache now, if necessary - if [ $NOW -ge $expiry ] || [ "$lastrun" = "0" ]; then - "__$1" > "$cachepath" - echo "$NOW" > "$lastpath" - fi - IFS= read line < "$cachepath"; printf "$line" -} - -case "$1" in - *left|*right) - eval items="\$$1" - for i in $items; do - case "$i" in \#*) continue ;; esac - get_status "$i" - done - ;; -esac diff --git a/usr/share/byobu/profiles/common b/usr/share/byobu/profiles/common index d34a74a6..e5268608 100644 --- a/usr/share/byobu/profiles/common +++ b/usr/share/byobu/profiles/common @@ -39,10 +39,10 @@ backtick 10 9999999 9999999 byobu-janitor backtick 11 9999999 9999999 printf "\005-1=" backtick 12 9999999 9999999 byobu-status color -backtick 1001 9999999 9999999 byobu-status-tmux screen_upper_left -backtick 1002 127 127 byobu-status-tmux screen_upper_right -backtick 1003 599 599 byobu-status-tmux screen_lower_left -backtick 1004 2 2 byobu-status-tmux screen_lower_right +backtick 1001 9999999 9999999 byobu-status screen_upper_left +backtick 1002 127 127 byobu-status screen_upper_right +backtick 1003 599 599 byobu-status screen_lower_left +backtick 1004 2 2 byobu-status screen_lower_right hardstatus alwayslastline diff --git a/usr/share/byobu/profiles/tmux b/usr/share/byobu/profiles/tmux index eb6610e5..cd047d20 100644 --- a/usr/share/byobu/profiles/tmux +++ b/usr/share/byobu/profiles/tmux @@ -79,7 +79,7 @@ set -g status-fg white set -g status-interval 1 set -g status-left-length 256 set -g status-right-length 256 -set -g status-left '#(byobu-status-tmux tmux_left)[' -set -g status-right ']#(byobu-status-tmux tmux_right)' +set -g status-left '#(byobu-status tmux_left)[' +set -g status-right ']#(byobu-status tmux_right)' set -g message-bg magenta set -g message-fg white diff --git a/usr/share/man/man1/byobu-status.1 b/usr/share/man/man1/byobu-status.1 index c2f127a2..6b7ef6e8 100644 --- a/usr/share/man/man1/byobu-status.1 +++ b/usr/share/man/man1/byobu-status.1 @@ -1,9 +1,9 @@ -.TH byobu-status 1 "21 Apr 2009" byobu "byobu" +.TH byobu-status 1 "15 Aug 2011" byobu "byobu" .SH NAME -byobu\-status \- Common starting point for running byobu status commands +byobu\-status \- displays status suitable for printing by the BYOBU_BACKEND .SH DESCRIPTION -\fBbyobu\-status\fP is a simple script that takes a single argument: a script defined in //usr/libexec/byobu. This wrapper is useful for doing some common functionality, like setting the cpu and/or io priority, determining sane defaults, pre/post processing. +\fBbyobu\-status\fP is a program periodically called by the BYOBU_BACKEND to gather the formatted status strings displayed in to lower status bar(s). .TP \fIhttp://launchpad.net/byobu\fP