* 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 <kirkland@canonical.com>
This commit is contained in:
Dustin Kirkland 2009-06-19 16:19:46 -05:00
commit 36f3a4c6fe
4 changed files with 32 additions and 78 deletions

View file

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

View file

@ -17,15 +17,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###########################################################
# 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,41 +35,20 @@ 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
[ -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"
fi
fi
# Source global status configuration
. "/etc/$PKG/statusrc" || true
# Source local status configuration
. "$HOME/.$PKG/status" || sed -i "s/-/_/g" "$HOME/.$PKG/status" || true
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
[ "$x" = "1" ] || exit 0
;;
--detail)
export P="$1"
if [ "$P" = "--detail" ]; then
VER=
if which dpkg-query >/dev/null; then
VER=`dpkg-query --show $PKG | awk '{print "-" $2 }'`
@ -91,13 +61,8 @@ case "$P" in
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"
else
eval x=\$$P || exit 1
[ "$x" = "1" ] || exit 0
[ -x "$DIR"/"$P" ] exec "$DIR"/"$P"
fi

6
debian/changelog vendored
View file

@ -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 <kirkland@ubuntu.com> Fri, 19 Jun 2009 14:59:28 -0500
-- Dustin Kirkland <kirkland@ubuntu.com> Fri, 19 Jun 2009 16:18:53 -0500
byobu (2.12-0ubuntu1) karmic; urgency=low

1
debian/install vendored
View file

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