* byobu-janitor: clean up old ~/.byobu/profile symlinks; guess the user's

colors and set them in ~/.byobu/colors
* byobu-select-profile, byobu-select-profile.1: deprecate the --set
  option, only support --background and --foreground now; update the
  documentation
This commit is contained in:
Dustin Kirkland 2009-12-04 10:53:43 -06:00
commit 18d62cac8e
4 changed files with 47 additions and 56 deletions

View file

@ -52,21 +52,42 @@ if [ -d "$HOME/.$OLDPKG" ] && [ ! -e "$HOME/.$PKG" ]; then
# Rename the config dir
mv -f "$HOME/.$OLDPKG" "$HOME/.$PKG"
ln -sf "$HOME/.$PKG" "$HOME/.$OLDPKG"
# 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
byobu-select-profile -s "$profile" >/dev/null 2>&1 || byobu-select-profile -s "$DEFAULT_PROFILE" >/dev/null 2>&1
fi
# Replace all instances of the old package name with the new
sed -i "s/$OLDPKG/$PKG/g" "$HOME/.$PKG"/* || true
fi
# Affects: First runs with no configuration
# Affects: First runs with no configuration, or broken profile symlinks
# Seed the configuration
[ -d "$HOME/.$PKG" ] || mkdir -p "$HOME/.$PKG"
[ -r "$PROFILE" ] || byobu-select-profile -s "$DEFAULT_PROFILE" >/dev/null 2>&1
if [ ! -r "$PROFILE" ]; then
# Set default colors
BG=W
FG=k
if [ -h "$PROFILE" ]; then
# Symlink is broken; try to guess chosen colors
color=$(ls -l "$PROFILE" | sed "s/^.* //")
case $color in
black|dark) BG=k; FG=W;;
dark_blue) BG=b; FG=W;;
dark_cyan) BG=c; FG=W;;
dark_green) BG=g; FG=W;;
dark_purple) BG=m; FG=W;;
dark_red) BG=r; FG=W;;
dark_yellow) BG=y; FG=W;;
light) BG=W; FG=k;;
light_blue) BG=B; FG=k;;
light_cyan) BG=C; FG=k;;
light_green) BG=G; FG=k;;
light_purple) BG=M; FG=k;;
light_red) BG=R; FG=k;;
light_yellow) BG=Y; FG=k;;
*) BG=W; FG=k;;
esac
fi
byobu-select-profile -b $BG -f $FG >/dev/null 2>&1
rm -f "$PROFILE" 2>/dev/null
ln -s /usr/share/$PKG/profiles/common "$PROFILE"
fi
[ -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"

View file

@ -30,9 +30,10 @@ COLORS="black blue cyan green purple red grey yellow"
usage () {
cat <<EOT
usage: byobu-select-profile [(-l|--list)][(-h|--help)][(-s|--set) PROFILE]
usage: byobu-select-profile [(-l|--list)][(-h|--help)]
-l,--list list available profiles
-s,--set PROFILE set profile
-b,--background set the background color
-f,--foreground set the foreground color
-h,--help this help
Without any parameters, runs interactively.
@ -40,10 +41,7 @@ EOT
}
# Initialize variables
BASE_DIR="/usr/share/$PKG"
PROFILE_DIR="$BASE_DIR/profiles"
FILE="$HOME"/."$PKG"/color
profile=""
selected=-1
color=
@ -122,38 +120,12 @@ prompt() {
done
}
setprofile() {
# Apply a profile by name or index
if [ -n "$1" ]; then
selected="$1"
else
selected="$SELECTED"
fi
i=0
found=0
profiles=$(listprofiles)
for x in $profiles; do
i=`expr $i + 1`
if [ "$i" = "$selected" -o "$x" = "$selected" ]; then
rm -f "$HOME/.$PKG/profile"
ln -s "$PROFILE_DIR/$x" "$HOME/.$PKG/profile"
found=1
echo
if [ -n "$STY" ]; then
echo `gettext 'If you are using the default set of keybindings, press\n<F5> to activate these changes.\n\nOtherwise, exit this screen session and start a new one.'`
else
echo `gettext 'Run "byobu" to activate'`
fi
echo
break
fi
done
if [ $found -eq 0 ]; then
echo "Invalid profile"
fi
}
getletter() {
count=$(echo "$1" | wc -c)
if [ "$count" = "2" ]; then
echo "$1"
return
fi
desc=$(echo "$1" | awk -F"_" '{print $1}')
color=$(echo "$1" | awk -F"_" '{print $2}')
COLORS="black blue cyan green purple red grey yellow"
@ -195,11 +167,6 @@ if [ $# -eq 0 ]; then
else
while true; do
case "$1" in
-s|--set)
setprofile "$2"
shift 2
break
;;
-b|--background)
setcolor "background" "$2"
shift 2

View file

@ -1,16 +1,14 @@
.TH select\-byobu\-profile 1 "14 Dec 2008" byobu "byobu"
.TH byobu\-select\-profile 1 "4 Dec 2009" byobu "byobu"
.SH NAME
select\-byobu\-profile \- Screen Profile Selector
byobu\-select\-profile \- select your Byobu foreground and background colors
.SH DESCRIPTION
\fBselect\-byobu\-profile\fP is an application that lists the available byobu screen profiles on a system and prompts the user to select one.
The selected profile will be symbolically linked into the current user's $HOME/.byobu/profile, if that file does not yet exist, or is currently a symbolic link.
\fBbyobu\-select\-profile\fP is an application that lists the available Byobu colors and allows you to select the foreground and background color.
.SH "SEE ALSO"
.PD 0
.TP
\fBscreen\fP(1)
\fBbyobu\fP(1)
.TP
\fIhttp://launchpad.net/byobu\fP

5
debian/changelog vendored
View file

@ -32,6 +32,11 @@ byobu (2.40) unreleased; urgency=low
profiles_generator/generate, profiles_generator/profile.skel,
rpm/byobu.spec: get rid of the generated profiles; now, everything is
handled by FOREGROUND and BACKGROUND colors, dynamically
* byobu-janitor: clean up old ~/.byobu/profile symlinks; guess the user's
colors and set them in ~/.byobu/colors
* byobu-select-profile, byobu-select-profile.1: deprecate the --set
option, only support --background and --foreground now; update the
documentation
-- Dustin Kirkland <kirkland@ubuntu.com> Tue, 10 Nov 2009 10:18:20 -0600