mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-21 22:13:19 -07:00
* 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)
This commit is contained in:
parent
ebe905defb
commit
33197a24e9
14 changed files with 94 additions and 121 deletions
12
debian/changelog
vendored
12
debian/changelog
vendored
|
@ -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 <kirkland@ubuntu.com> Thu, 11 Aug 2011 10:31:31 -0500
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 <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}/.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"
|
69
usr/bin/byobu-status-tmux
Executable file
69
usr/bin/byobu-status-tmux
Executable file
|
@ -0,0 +1,69 @@
|
|||
#!/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_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
|
|
@ -1,77 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# byobu-statusd: byobu's status gathering daemon
|
||||
#
|
||||
# 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"
|
||||
|
||||
# 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
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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="-" ;;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue