diff --git a/debian/changelog b/debian/changelog index fed747d1..026006e6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,18 @@ byobu (4.30) unreleased; urgency=low - clean up and make window colorings more consistent * usr/bin/byobu-status: - speed up disabled status runs + * usr/bin/byobu-statusd, usr/bin/byobu-status-print, usr/bin/byobu- + status-tmux, usr/bin/Makefile.am, usr/lib/byobu/battery, + usr/lib/byobu/.constants, usr/lib/byobu/disk, + usr/lib/byobu/mem_used, usr/lib/byobu/raid, usr/lib/byobu/.shutil, + usr/lib/byobu/swap, usr/lib/byobu/wifi_quality, + usr/share/byobu/profiles/tmux: + - support tmux status, using a cached print mechanism and a list of + left and right status items + - drop the failed byobu-statusd experiment and its byobu-status-print + helper + - add a PCT constant, required to support both screen and tmux + - fix a bug/typo in shutil (should be /proc/uptime) -- Dustin Kirkland Thu, 11 Aug 2011 10:31:31 -0500 diff --git a/usr/bin/Makefile.am b/usr/bin/Makefile.am index 771c0f07..a2d8f90b 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-statusd byobu-status-detail byobu-status-print 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-tmux byobu-status-detail byobu-shell diff --git a/usr/bin/byobu-status-print b/usr/bin/byobu-status-print deleted file mode 100755 index d95733c1..00000000 --- a/usr/bin/byobu-status-print +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# -# byobu-status-print: concatenate the status cache -# - this script must be *extremely* fast -# -# 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}/.dirs" - -while read i; do - cache="$BYOBU_RUN_DIR/status/$i" - if [ -s "$cache" ]; then - IFS= - read c < "$cache" - printf "%s" "$c" - fi -done < "$BYOBU_CONFIG_DIR/status.$1" diff --git a/usr/bin/byobu-status-tmux b/usr/bin/byobu-status-tmux new file mode 100755 index 00000000..d1a9d8fc --- /dev/null +++ b/usr/bin/byobu-status-tmux @@ -0,0 +1,69 @@ +#!/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_RUN_DIR/.last" + +# Source configurations +for i in "${BYOBU_PREFIX}/share/$PKG/status/statusrc" "$BYOBU_CONFIG_DIR/statusrc"; do + [ -r "$i" ] && . "$i" +done + +# Get the current timestamp +get_now; NOW=${_RET} + +get_status() { + local cachepath="$BYOBU_RUN_DIR/status/$1" + local lastpath="$BYOBU_RUN_DIR/.last/$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) + IFS= read items < "$BYOBU_CONFIG_DIR/status.tmux.left" + for i in $items; do + get_status "$i" + done + ;; + right) + IFS= read items < "$BYOBU_CONFIG_DIR/status.tmux.right" + for i in $items; do + get_status "$i" + done + + ;; +esac diff --git a/usr/bin/byobu-statusd b/usr/bin/byobu-statusd deleted file mode 100755 index 04aedc71..00000000 --- a/usr/bin/byobu-statusd +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh -# -# byobu-statusd: byobu's status gathering daemon -# -# 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" - -# Clean and create cache directories -rm -rf "$BYOBU_RUN_DIR/status" "$BYOBU_RUN_DIR/.last" -mkdir -p "$BYOBU_RUN_DIR/status" "$BYOBU_RUN_DIR/.last" - -# 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 - -# Run each status function as necessary -while true; do - # Make sure status is not disabled - if [ -f "$BYOBU_CONFIG_DIR/status.disable" ]; then - rm -f "$BYOBU_RUN_DIR/status"/* "$BYOBU_RUN_DIR/.last"/* - exit 0 - fi - get_now; now=${_RET} - # Re-source configuration, if changed since last run - for i in "${BYOBU_PREFIX}/share/$PKG/status/status" "${BYOBU_PREFIX}/share/$PKG/status/statusrc" "$BYOBU_CONFIG_DIR/status" "$BYOBU_CONFIG_DIR/statusrc"; do - [ -r "$i" ] && [ "$i" -nt "$BYOBU_RUN_DIR/status" ] && . "$i" - done - for i in "$BYOBU_PREFIX/lib/$PKG/"*; do - case "$i" in - */time_binary|*/Makefile.am) continue ;; - esac - i=${i##*/} - cachepath="$BYOBU_RUN_DIR/status/$i" - lastpath="$BYOBU_RUN_DIR/.last/$i" - # Check if this status is enabled - eval x="\$$i" - if [ "$x" != "1" ]; then - # This item is disabled; clean up and continue - rm -f "$cachepath" "$lastpath" - continue - fi - [ -r "$lastpath" ] && read lastrun < "$lastpath" || lastrun=0 - status_freq "$i" - expiry=$(($lastrun+$_RET)) - find_script "$i" && path="$_RET" || path=/dev/null - # Re-source status function, if changed since last run - if [ "$path" -nt "$lastpath" ] || [ ! -e "$lastpath" ]; then - . "$path" - lastrun=0 - fi - # Update cache now, if necessary - if [ $now -ge $expiry ] || [ "$lastrun" = "0" ]; then - "__$i" > "$cachepath" - echo "$now" > "$lastpath" - fi - done - sleep 2 -done -exit 0 diff --git a/usr/lib/byobu/.constants b/usr/lib/byobu/.constants index e249ee11..7caeaabd 100755 --- a/usr/lib/byobu/.constants +++ b/usr/lib/byobu/.constants @@ -53,11 +53,13 @@ case "$BYOBU_BACKEND" in export BYOBU_BACKEND BYOBU_ARG_VERSION="-V" ESC= + PCT="%%" ;; *) export BYOBU_BACKEND="screen" BYOBU_ARG_VERSION="-v" ESC="\005" + PCT="%" ;; esac diff --git a/usr/lib/byobu/.shutil b/usr/lib/byobu/.shutil index 60c5d223..30392b21 100755 --- a/usr/lib/byobu/.shutil +++ b/usr/lib/byobu/.shutil @@ -260,7 +260,7 @@ status_freq() { get_now() { if [ -n "${BASH_VERSION}" ] && [ -n "${SECONDS}" ]; then _RET=${SECONDS} - elif [ -r /proc/cpuinfo ]; then + elif [ -r /proc/uptime ]; then # return the integer part of the first item in /proc/uptime local s c read s c < /proc/uptime diff --git a/usr/lib/byobu/battery b/usr/lib/byobu/battery index e266446e..138c1747 100755 --- a/usr/lib/byobu/battery +++ b/usr/lib/byobu/battery @@ -63,7 +63,7 @@ __battery() { color="G k" bcolor="b G k" fi - percent="$percent%" + percent="$percent$PCT" case $state in charging) sign="+" ;; discharging) sign="-" ;; diff --git a/usr/lib/byobu/disk b/usr/lib/byobu/disk index 15c1b485..0e31e10c 100755 --- a/usr/lib/byobu/disk +++ b/usr/lib/byobu/disk @@ -40,7 +40,7 @@ __disk() { pct=${pct%?}; # take off the '%' _UNIT=${unit}; _SIZE=${size}; _PCT=${pct}; color b M W; echo -n "$_SIZE"; color -; color M W; echo -n "${_UNIT}B,"; color -; - color b M W; echo -n "$_PCT"; color -; color M W; echo -n "%" ; color --; + color b M W; echo -n "$_PCT"; color -; color M W; echo -n "$PCT" ; color --; } # vi: syntax=sh ts=4 noexpandtab diff --git a/usr/lib/byobu/mem_used b/usr/lib/byobu/mem_used index e7bab8f4..c6d50818 100755 --- a/usr/lib/byobu/mem_used +++ b/usr/lib/byobu/mem_used @@ -47,7 +47,7 @@ __mem_used() { fo_cached=$(($kb_main_free + $buffers_plus_cached)) fpdiv $((100*${fo_buffers})) "${total}" 0; f=${_RET} - color b g W; printf "%s" "$f"; color -; color g W; printf "%%"; color -- + color b g W; printf "%s" "$f"; color -; color g W; printf "%s" "$PCT"; color -- } # vi: syntax=sh ts=4 noexpandtab diff --git a/usr/lib/byobu/raid b/usr/lib/byobu/raid index 94e7b477..202c1fc3 100755 --- a/usr/lib/byobu/raid +++ b/usr/lib/byobu/raid @@ -25,13 +25,13 @@ __raid_detail() { __raid() { while read line; do - local pct="%" p msg + local p msg # Errors in your raid case "$line" in *\ blocks\ *\[*_*\]$) [ -z "${msg}" ] && msg="RAID";; *%*) - p="${line%%${pct}*}${pct}"; p=${p##* }; + p="${line%%${PCT}*}${PCT}"; p=${p##* }; [ -z "$msg" ] && msg="RAID" msg="$msg,$p";; esac diff --git a/usr/lib/byobu/swap b/usr/lib/byobu/swap index c2be0073..fe89126f 100755 --- a/usr/lib/byobu/swap +++ b/usr/lib/byobu/swap @@ -52,7 +52,7 @@ __swap() { unit="KB" fi color b G W; printf "s%s" "$mem"; color -; color G W; printf "%s," "$unit"; color -; - color b G W; printf "%s" "$f"; color -; color G W; printf "%%"; color -- + color b G W; printf "%s" "$f"; color -; color G W; printf "%s" "$PCT"; color -- } # vi: syntax=sh ts=4 noexpandtab diff --git a/usr/lib/byobu/wifi_quality b/usr/lib/byobu/wifi_quality index 48225633..10ec3f4f 100755 --- a/usr/lib/byobu/wifi_quality +++ b/usr/lib/byobu/wifi_quality @@ -41,7 +41,7 @@ __wifi_quality() { quality="0" fi [ "$quality" = "0" ] && return - printf "${ICON_WIFI}"; color b C k; printf "%s" "$bitrate"; color -; color C k; printf "%s," "Mbps"; color -; color b C k; printf "%s" "$quality"; color -; color C k; printf "%%"; color -- + printf "${ICON_WIFI}"; color b C k; printf "%s" "$bitrate"; color -; color C k; printf "%s," "Mbps"; color -; color b C k; printf "%s" "$quality"; color -; color C k; printf "%s" "$PCT"; color -- } # vi: syntax=sh ts=4 noexpandtab diff --git a/usr/share/byobu/profiles/tmux b/usr/share/byobu/profiles/tmux index cd773c1d..cd4981cd 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 logo)' -set -g status-right '%Y-%m-%d %H:%M:%S' +set -g status-left '#(byobu-status-tmux left)[' +set -g status-right ']#(byobu-status-tmux right)#[default]%Y-%m-%d %H:%M:%S' set -g message-bg magenta set -g message-fg white