* 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
This commit is contained in:
Dustin Kirkland 2011-08-15 13:03:55 -05:00
commit e6277a3ba3
7 changed files with 50 additions and 87 deletions

5
debian/changelog vendored
View file

@ -29,6 +29,11 @@ byobu (4.30) unreleased; urgency=low
- fix default status - fix default status
* usr/share/byobu/profiles/common, usr/share/byobu/profiles/tmux: * usr/share/byobu/profiles/common, usr/share/byobu/profiles/tmux:
- drop backticks and double printing of date/time in 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 <kirkland@ubuntu.com> Thu, 11 Aug 2011 10:31:31 -0500 -- Dustin Kirkland <kirkland@ubuntu.com> Thu, 11 Aug 2011 10:31:31 -0500

View file

@ -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

View file

@ -1,7 +1,8 @@
#!/bin/sh -e #!/bin/sh
# #
# byobu-status # byobu-status: byobu's cached status gathering
# Copyright (C) 2008 Canonical Ltd. #
# Copyright (C) 2011 Dustin Kirkland
# #
# Authors: Dustin Kirkland <kirkland@ubuntu.com> # Authors: Dustin Kirkland <kirkland@ubuntu.com>
# #
@ -21,15 +22,44 @@ PKG="byobu"
[ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX
. "${BYOBU_PREFIX}/lib/${PKG}/.common" . "${BYOBU_PREFIX}/lib/${PKG}/.common"
# Make sure status is not disabled
[ -f "$BYOBU_CONFIG_DIR/status.disable" ] && exit 0 [ -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 # 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 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" [ -r "$i" ] && . "$i"
done done
export P="$1" # Get the current timestamp
case "$P" in 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) --detail)
VER= VER=
if command -v dpkg-query >/dev/null; then if command -v dpkg-query >/dev/null; then
@ -56,13 +86,4 @@ case "$P" in
[ -z "$BACKGROUND" ] && BACKGROUND="k" [ -z "$BACKGROUND" ] && BACKGROUND="k"
printf "$ESC{= $BACKGROUND$FOREGROUND}" printf "$ESC{= $BACKGROUND$FOREGROUND}"
;; ;;
*)
eval x="\$$P" || exit 1
[ "$x" = "1" ] || exit 0
shift
find_script "$P" && . "${_RET}"
eval "__${P}"
;;
esac esac
# vi: syntax=sh ts=4 noexpandtab

View file

@ -1,63 +0,0 @@
#!/bin/sh
#
# byobu-status-tmux: byobu's status gathering for tmux
#
# Copyright (C) 2011 Dustin Kirkland
#
# Authors: Dustin Kirkland <kirkland@ubuntu.com>
#
# 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 <http://www.gnu.org/licenses/>.
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

View file

@ -39,10 +39,10 @@ backtick 10 9999999 9999999 byobu-janitor
backtick 11 9999999 9999999 printf "\005-1=" backtick 11 9999999 9999999 printf "\005-1="
backtick 12 9999999 9999999 byobu-status color backtick 12 9999999 9999999 byobu-status color
backtick 1001 9999999 9999999 byobu-status-tmux screen_upper_left backtick 1001 9999999 9999999 byobu-status screen_upper_left
backtick 1002 127 127 byobu-status-tmux screen_upper_right backtick 1002 127 127 byobu-status screen_upper_right
backtick 1003 599 599 byobu-status-tmux screen_lower_left backtick 1003 599 599 byobu-status screen_lower_left
backtick 1004 2 2 byobu-status-tmux screen_lower_right backtick 1004 2 2 byobu-status screen_lower_right
hardstatus alwayslastline hardstatus alwayslastline

View file

@ -79,7 +79,7 @@ set -g status-fg white
set -g status-interval 1 set -g status-interval 1
set -g status-left-length 256 set -g status-left-length 256
set -g status-right-length 256 set -g status-right-length 256
set -g status-left '#(byobu-status-tmux tmux_left)[' set -g status-left '#(byobu-status tmux_left)['
set -g status-right ']#(byobu-status-tmux tmux_right)' set -g status-right ']#(byobu-status tmux_right)'
set -g message-bg magenta set -g message-bg magenta
set -g message-fg white set -g message-fg white

View file

@ -1,9 +1,9 @@
.TH byobu-status 1 "21 Apr 2009" byobu "byobu" .TH byobu-status 1 "15 Aug 2011" byobu "byobu"
.SH NAME .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 .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 .TP
\fIhttp://launchpad.net/byobu\fP \fIhttp://launchpad.net/byobu\fP