* byobu, byobu-janitor, debian/install, profiles/common,

profiles/profile.skel: remove janitorial logic scattered across
    several scripts and put it in a single place; call this script before
    launching byobu, and then only once a day or when the user refreshes
    their profile


Signed-off-by: Dustin Kirkland <kirkland@canonical.com>
This commit is contained in:
Dustin Kirkland 2009-06-19 19:09:45 -05:00
commit a96a0642df
6 changed files with 77 additions and 86 deletions

93
byobu
View file

@ -1,7 +1,7 @@
#!/bin/sh
#
# screen wrapper script
# Copyright (C) 2008 Canonical Ltd.
# byobu - screen wrapper script
# Copyright (C) 2008-2009 Canonical Ltd.
#
# Authors: Dustin Kirkland <kirkland@canonical.com>
#
@ -17,93 +17,20 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
OLDPKG="screen-profiles"
PKG="byobu"
SCREEN_REAL="screen"
# Upgrade old config dir to the new name
[ -d "$HOME/.$OLDPKG" -a ! -e "$HOME/.$PKG" ] && mv -f "$HOME/.$OLDPKG" "$HOME/.$PKG"
# Sanitize the environment
byobu-janitor
# Create the .$PKG directory, if it doesn't already exist
[ -d "$HOME/.$PKG" ] || mkdir -p "$HOME/.$PKG"
# Use $SCREENRC if non-empty, and readable; otherwise, use the one in $HOME
[ -n "$SCREENRC" -a -r "$SCREENRC" ] || SCREENRC="$HOME/.screenrc"
# If $SCREENRC exists but $HOME/.$PKG/profile does not,
# this shows that the user has an existing custom screen configuration,
# and thus we will not force $PKG on them.
if [ -r "$SCREENRC" -a ! -e "$HOME/.$PKG/profile" -a ! -h "$HOME/.$PKG/profile" ]; then
exec $SCREEN_REAL -c "$SCREENRC" "$@"
exit $?
fi
# If the user is running byobu with some arguments, but has not selected
# their profile yet, don't bother them with profile selection at this time
if [ $# -gt 0 -a ! -h "$HOME/.$PKG/profile" ]; then
exec $SCREEN_REAL "$@"
exit $?
fi
DEFAULT_PROFILE="light"
# Ensure that the user has selected a screen profile
profile="$HOME/.$PKG/profile"
[ -h "$profile" ] || select-screen-profile -s "$DEFAULT_PROFILE"
# Previously, profiles were prepended with ubuntu-.
# This is no longer the case, for cross-distro compatibility.
# Try to fix broken symlinks for upgrading users, or prompt to reselect.
if [ -h "$profile" -a ! -r "$profile" ]; then
if stat "$profile" | head -n1 | grep -qs ".*->.*ubuntu\-.*"; then
newsrc=$(stat "$profile" | head -n1 | sed "s/.*\`//" | sed "s/'.*//" | sed "s/ubuntu-//")
if [ -r "$newsrc" ]; then
ln -sf "$newsrc" "$profile"
else
select-screen-profile -s "$DEFAULT_PROFILE"
fi
elif stat "$profile" | head -n1 | grep -qs ".*->.*plain'$"; then
ln -sf "/usr/share/$PKG/profiles/NONE" "$profile"
else
select-screen-profile -s "$DEFAULT_PROFILE"
fi
fi
if [ ! -r "$profile" ]; then
echo
echo "Your selected profile is not accessible."
echo
echo "Either select a different profile:"
echo " $ select-screen-profile"
echo
echo "Or install the extras package:"
echo " $ sudo apt-get install $PKG-extras"
echo
exit 1
fi
# Ensure that their keybindings are seeded
[ -s "$HOME/.$PKG/keybindings" ] || echo "source /usr/share/$PKG/keybindings/common" > "$HOME/.$PKG/keybindings"
sed -i "s/$OLDPKG/$PKG/g" "$HOME/.$PKG/keybindings"
# Ensure that the user's configuration is seeded
[ -r "$HOME/.$PKG/status" ] || touch "$HOME/.$PKG/status"
[ -r "$HOME/.$PKG/windows" ] || touch "$HOME/.$PKG/windows"
if grep -qs "^[^#]" "$HOME/.$PKG/windows"; then
# User has some default windows, so don't launch motd+shell
DEFAULT_WINDOW=
else
# User has no default windows, so launch motd+shell
# Launch motd+shell, unless the user has default windows set to launch
[ -n "$SHELL" ] || SHELL="/bin/sh"
[ -x "$SHELL" ] || SHELL="/bin/sh"
DEFAULT_WINDOW="$SHELL -c motd+shell"
fi
# Ensure that the user's $SCREENRC at least exists
[ -r "$SCREENRC" ] || touch "$SCREENRC"
grep -qs "^[^#]" "$HOME/.$PKG/windows" && DEFAULT_WINDOW=
# Now let's execute screen!
if [ "$#" = "0" ]; then
[ -n "$SHELL" -a -x "$SHELL" ] || SHELL="/bin/sh"
exec $SCREEN_REAL -c "/usr/share/$PKG/profiles/byoburc" $DEFAULT_WINDOW
exec screen -c "/usr/share/$PKG/profiles/byoburc" $DEFAULT_WINDOW
else
exec $SCREEN_REAL -c "$HOME/.$PKG/profile" "$@"
exec screen -c "$HOME/.$PKG/profile" "$@"
fi

57
byobu-janitor Normal file
View file

@ -0,0 +1,57 @@
#!/bin/sh -e
#
# byobu-janitor - a collection of byobu tasks that ensure a clean
# environtment and smooth upgrades
#
# Copyright (C) 2009 Canonical Ltd.
#
# Authors: Dustin Kirkland <kirkland@canonical.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/>.
OLDPKG="screen-profiles"
PKG="byobu"
DEFAULT_PROFILE="light"
PROFILE="$HOME/.$PKG/profile"
# Affects: Upgrades from screen-profiles
# If the old config dir exists, but the new one doesn't, provide a migration mechanism.
if [ -d "$HOME/.$OLDPKG" ] && [ ! -e "$HOME/.$PKG" ]; then
# Rename the config dir
mv -f "$HOME/.$OLDPKG" "$HOME/.$PKG"
ln -sf "$HOME/.$PKG" "$HOME/.$OLDPKG"
# Replace all instances of the old package name with the new
sed -i "s/$OLDPKG/$PKG/g" "$HOME/.$PKG"/*
# Fix the chosen profile symlink
if [ -h "$PROFILE" ]; then
# Determine the chosen profile color
profile=`readlink "$PROFILE" | sed "s:^.*-::"`
# Try to set that color, if it exists, otherwise set to default
select-screen-profile -s "$profile" >/dev/null 2>&1 || select-screen-profile -s "$DEFAULT_PROFILE" >/dev/null 2>&1
fi
fi
# Affects: First runs with no configuration
# Seed the configuration
[ -d "$HOME/.$PKG" ] || mkdir -p "$HOME/.$PKG"
[ -r "$PROFILE" ] || select-screen-profile -s "$DEFAULT_PROFILE" >/dev/null 2>&1
[ -s "$HOME/.$PKG/keybindings" ] || echo "source /usr/share/$PKG/keybindings/common" > "$HOME/.$PKG/keybindings"
[ -r "$HOME/.$PKG/status" ] || touch "$HOME/.$PKG/status"
[ -r "$HOME/.$PKG/windows" ] || touch "$HOME/.$PKG/windows"
[ -r "$HOME/.screenrc" ] || touch "$HOME/.screenrc"
# Affects: Upgrades from <= byobu-2.11
# The status scripts used to have hyphens in their name, but now use
# underscores such that we can source the file as a shell snippet;
# fix existing status configuration.
sed -i "s/-/_/g" "$HOME/.$PKG/status"

7
debian/changelog vendored
View file

@ -13,11 +13,16 @@ byobu (2.13) unreleased; urgency=low
* byobu-status: move all of the cleanup hacks to byobu-janitor; create
a find_script() function that allows for scripts in both /usr/lib and
$HOME/.byobu
* byobu, byobu-janitor, debian/install, profiles/common,
profiles/profile.skel: remove janitorial logic scattered across
several scripts and put it in a single place; call this script before
launching byobu, and then only once a day or when the user refreshes
their profile
[ Ciemon Dunville ]
* byobu.1: reflect the keybinding toggle change to Ctrl-a-!
-- Dustin Kirkland <kirkland@ubuntu.com> Fri, 19 Jun 2009 17:50:59 -0500
-- Dustin Kirkland <kirkland@ubuntu.com> Fri, 19 Jun 2009 19:09:36 -0500
byobu (2.12-0ubuntu1) karmic; urgency=low

1
debian/install vendored
View file

@ -14,6 +14,7 @@ byobu usr/bin
byobu-config usr/bin
byobu-status usr/bin
byobu-status-detail usr/bin
byobu-janitor usr/bin
screen-launcher-install usr/share/byobu
screen-launcher-uninstall usr/share/byobu
motd+shell usr/bin

View file

@ -32,6 +32,7 @@ msgwait 1
# ~600 ~10 minutes
# ~180 ~3 minutes
# ~60 ~1 minute
backtick 10 86399 86399 byobu-janitor
backtick 99 86011 86011 byobu-status logo
backtick 100 599 599 byobu-status release
backtick 101 181 181 byobu-status updates_available

View file

@ -23,7 +23,7 @@
source /usr/share/byobu/profiles/common
# Window tabs, second to last line
caption always "%{kW}%?%-Lw%?%{bw}%n*%f %t%?(%u)%?%{kW}%?%+Lw%? %= %{= Wk}%110`%109`%122`%111`"
caption always "%{kW}%?%-Lw%?%{bw}%n*%f %t%?(%u)%?%{kW}%?%+Lw%? %= %{= Wk}%110`%109`%122`%111`%10`"
# Status string, last line
hardstatus string '%99`%{= Wk} %100`%112`%= %102`%101`%127`%114`%115`%108`%125`%126`%113`%119`%117`%116`%106`%104`%103`%105`%107`%123`%120`%121`'