mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-22 22:34:23 -07:00
byobu-config, byobu-select-profile: rework to independently select
background color and foreground color, rather than profile
This commit is contained in:
parent
bee9747c29
commit
8b829a6e7c
3 changed files with 119 additions and 54 deletions
45
byobu-config
45
byobu-config
|
@ -85,15 +85,16 @@ def menu(screen, size, isInstalled):
|
||||||
installtext=_("Byobu currently does not launch at login (toggle on)")
|
installtext=_("Byobu currently does not launch at login (toggle on)")
|
||||||
|
|
||||||
|
|
||||||
li = Listbox(height = 8, width = 60, returnExit = 1)
|
li = Listbox(height = 9, width = 60, returnExit = 1)
|
||||||
li.append(_("Help"), 1)
|
li.append(_("Help"), 1)
|
||||||
li.append(_("Change Byobu's colors"), 2)
|
li.append(_("Change Byobu's background color"), 2)
|
||||||
li.append(_("Toggle status notifications"), 3)
|
li.append(_("Change Byobu's foreground color"), 3)
|
||||||
li.append(_("Change keybinding set"), 4)
|
li.append(_("Toggle status notifications"), 4)
|
||||||
li.append(_("Change escape sequence"), 5)
|
li.append(_("Change keybinding set"), 5)
|
||||||
li.append(_("Create new windows"), 6)
|
li.append(_("Change escape sequence"), 6)
|
||||||
li.append(_("Manage default windows"), 7)
|
li.append(_("Create new windows"), 7)
|
||||||
li.append(installtext, 8)
|
li.append(_("Manage default windows"), 8)
|
||||||
|
li.append(installtext, 9)
|
||||||
bb = ButtonBar(screen, (("Exit", "exit", ESC),), compact=1)
|
bb = ButtonBar(screen, (("Exit", "exit", ESC),), compact=1)
|
||||||
|
|
||||||
g = GridForm(screen, _(" Byobu Configuration Menu"), 1, 2)
|
g = GridForm(screen, _(" Byobu Configuration Menu"), 1, 2)
|
||||||
|
@ -135,7 +136,7 @@ def help(screen, size, config):
|
||||||
|
|
||||||
return 100
|
return 100
|
||||||
|
|
||||||
def profile(screen, size):
|
def select_color(screen, size, layer):
|
||||||
li = Listbox(height = 8, width = 60, scroll = 1, returnExit = 1)
|
li = Listbox(height = 8, width = 60, scroll = 1, returnExit = 1)
|
||||||
|
|
||||||
for choice in commands.getoutput('byobu-select-profile -l').splitlines():
|
for choice in commands.getoutput('byobu-select-profile -l').splitlines():
|
||||||
|
@ -143,12 +144,20 @@ def profile(screen, size):
|
||||||
|
|
||||||
bb = ButtonBar(screen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact = 1)
|
bb = ButtonBar(screen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact = 1)
|
||||||
|
|
||||||
g = GridForm(screen, _("Which profile would you like to use?"), 1, 2)
|
if layer == "foreground":
|
||||||
|
g = GridForm(screen, _("Choose a foreground color:"), 1, 2)
|
||||||
|
else:
|
||||||
|
g = GridForm(screen, _("Choose a background color:"), 1, 2)
|
||||||
|
|
||||||
g.add(li, 0, 0, padding=(4,2,4,2))
|
g.add(li, 0, 0, padding=(4,2,4,2))
|
||||||
g.add(bb, 0, 1, padding=(1,1,0,0))
|
g.add(bb, 0, 1, padding=(1,1,0,0))
|
||||||
|
|
||||||
if bb.buttonPressed(g.runOnce()) != "cancel":
|
if bb.buttonPressed(g.runOnce()) != "cancel":
|
||||||
commands.getoutput('byobu-select-profile --set %s' % li.current())
|
commands.getoutput("echo %s > /tmp/out" % layer)
|
||||||
|
if layer == "foreground":
|
||||||
|
commands.getoutput('byobu-select-profile --foreground %s' % li.current())
|
||||||
|
else:
|
||||||
|
commands.getoutput('byobu-select-profile --background %s' % li.current())
|
||||||
reload_required()
|
reload_required()
|
||||||
return 100
|
return 100
|
||||||
|
|
||||||
|
@ -498,18 +507,20 @@ def main():
|
||||||
if tag == 1:
|
if tag == 1:
|
||||||
tag = help(screen, size, config)
|
tag = help(screen, size, config)
|
||||||
elif tag == 2:
|
elif tag == 2:
|
||||||
tag = profile(screen, size)
|
tag = select_color(screen, size, "background")
|
||||||
elif tag == 3:
|
elif tag == 3:
|
||||||
tag = togglestatus(screen, size)
|
tag = select_color(screen, size, "foreground")
|
||||||
elif tag == 4:
|
elif tag == 4:
|
||||||
|
tag = togglestatus(screen, size)
|
||||||
|
elif tag == 5:
|
||||||
tag = keybindings(screen, size)
|
tag = keybindings(screen, size)
|
||||||
elif tag == 5:
|
elif tag == 6:
|
||||||
tag = chgesc(screen, size)
|
tag = chgesc(screen, size)
|
||||||
elif tag == 6:
|
|
||||||
tag = newwindow(screen, size)
|
|
||||||
elif tag == 7:
|
elif tag == 7:
|
||||||
tag = defaultwindows(screen, size)
|
tag = newwindow(screen, size)
|
||||||
elif tag == 8:
|
elif tag == 8:
|
||||||
|
tag = defaultwindows(screen, size)
|
||||||
|
elif tag == 9:
|
||||||
tag = install(screen, size, isInstalled)
|
tag = install(screen, size, isInstalled)
|
||||||
isInstalled=(tag == 100)
|
isInstalled=(tag == 100)
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@ PKG="byobu"
|
||||||
|
|
||||||
TEXTDOMAIN="$PKG"
|
TEXTDOMAIN="$PKG"
|
||||||
|
|
||||||
|
COLORS="black blue cyan green purple red grey yellow"
|
||||||
|
|
||||||
usage () {
|
usage () {
|
||||||
cat <<EOT
|
cat <<EOT
|
||||||
usage: byobu-select-profile [(-l|--list)][(-h|--help)][(-s|--set) PROFILE]
|
usage: byobu-select-profile [(-l|--list)][(-h|--help)][(-s|--set) PROFILE]
|
||||||
|
@ -40,8 +42,10 @@ EOT
|
||||||
# Initialize variables
|
# Initialize variables
|
||||||
BASE_DIR="/usr/share/$PKG"
|
BASE_DIR="/usr/share/$PKG"
|
||||||
PROFILE_DIR="$BASE_DIR/profiles"
|
PROFILE_DIR="$BASE_DIR/profiles"
|
||||||
|
FILE="$HOME"/."$PKG"/color
|
||||||
profile=""
|
profile=""
|
||||||
selected=-1
|
selected=-1
|
||||||
|
color=
|
||||||
|
|
||||||
assert_symlink() {
|
assert_symlink() {
|
||||||
if [ -e "$1" ]; then
|
if [ -e "$1" ]; then
|
||||||
|
@ -58,47 +62,42 @@ assert_symlink "$HOME/.$PKG/profile"
|
||||||
|
|
||||||
listprofiles() {
|
listprofiles() {
|
||||||
# Display list of profiles, one per line
|
# Display list of profiles, one per line
|
||||||
# Start with basic profiles
|
for x in $COLORS; do
|
||||||
basename $(ls $PROFILE_DIR/NONE 2>/dev/null) 2>/dev/null
|
echo "dark_$x"
|
||||||
basename $(ls $PROFILE_DIR/light 2>/dev/null) 2>/dev/null
|
echo "light_$x"
|
||||||
basename $(ls $PROFILE_DIR/dark 2>/dev/null) 2>/dev/null
|
|
||||||
basename $(ls $PROFILE_DIR/black 2>/dev/null) 2>/dev/null
|
|
||||||
# Now, list advanced profiles
|
|
||||||
for x in $(ls $PROFILE_DIR/*_* 2>/dev/null); do
|
|
||||||
x=$(basename "$x")
|
|
||||||
if [ $x = "common" -o $x = "misc" ]; then
|
|
||||||
# Skip the common profile, no value there
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
echo "$x"
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt() {
|
prompt() {
|
||||||
# Prompt the user to choose among the available profiles
|
which="$1"
|
||||||
echo
|
|
||||||
echo `gettext "Select a screen profile: "`
|
|
||||||
i=0
|
|
||||||
profiles=$(listprofiles)
|
|
||||||
for x in $profiles; do
|
|
||||||
i=$(expr $i + 1)
|
|
||||||
desc=" "
|
|
||||||
if [ "$x" = "light" ]; then
|
|
||||||
simple=$i
|
|
||||||
fi
|
|
||||||
[ $i -lt 10 ] && i=" $i"
|
|
||||||
echo " $i. $x$desc"
|
|
||||||
done
|
|
||||||
echo
|
|
||||||
selected=x
|
|
||||||
count=1
|
count=1
|
||||||
|
selected=-1
|
||||||
while /bin/true; do
|
while /bin/true; do
|
||||||
if [ $count -gt 5 ]; then
|
if [ $count -gt 5 ]; then
|
||||||
echo `gettext "ERROR: Invalid selection"`
|
echo `gettext "ERROR: Invalid selection"`
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
count=`expr $count + 1`
|
count=$(expr $count + 1)
|
||||||
if [ -z "$selected" -a ! -z "$simple" ]; then
|
echo
|
||||||
|
if [ "$which" = "foreground" ]; then
|
||||||
|
echo `gettext 'Select the foreground color: '`
|
||||||
|
simple="black"
|
||||||
|
else
|
||||||
|
echo `gettext 'Select the background color: '`
|
||||||
|
simple="grey"
|
||||||
|
fi
|
||||||
|
i=1
|
||||||
|
for x in $COLORS; do
|
||||||
|
test $i -lt 10 2>/dev/null && echo -n " " || echo -n " "
|
||||||
|
echo "$i. dark_$x"
|
||||||
|
i=$(expr $i + 1)
|
||||||
|
[ "$simple" = "$x" ] && simple=$i
|
||||||
|
test $i -lt 10 2>/dev/null && echo -n " " || echo -n " "
|
||||||
|
echo "$i. light_$x"
|
||||||
|
i=$(expr $i + 1)
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
if [ -z "$selected" -a -n "$simple" ]; then
|
||||||
selected="$simple"
|
selected="$simple"
|
||||||
elif ! test $selected -gt 0 2>/dev/null; then
|
elif ! test $selected -gt 0 2>/dev/null; then
|
||||||
echo -n "`gettext 'Choose'` 1-$i [$simple]: "
|
echo -n "`gettext 'Choose'` 1-$i [$simple]: "
|
||||||
|
@ -107,10 +106,20 @@ prompt() {
|
||||||
echo -n "`gettext 'Choose'` 1-$i [$simple]: "
|
echo -n "`gettext 'Choose'` 1-$i [$simple]: "
|
||||||
selected=`head -n1`
|
selected=`head -n1`
|
||||||
else
|
else
|
||||||
break
|
i=1
|
||||||
|
for x in $COLORS; do
|
||||||
|
color="dark_$x"
|
||||||
|
[ "$i" = "$selected" ] && break
|
||||||
|
i=$(expr $i + 1)
|
||||||
|
color="light_$x"
|
||||||
|
[ "$i" = "$selected" ] && break
|
||||||
|
i=$(expr $i + 1)
|
||||||
|
done
|
||||||
|
echo `gettext "Selected"` " [$color]"
|
||||||
|
setcolor "$which" "$color"
|
||||||
|
return 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
SELECTED="$selected"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setprofile() {
|
setprofile() {
|
||||||
|
@ -144,12 +153,46 @@ setprofile() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getletter() {
|
||||||
|
desc=$(echo "$1" | awk -F"_" '{print $1}')
|
||||||
|
color=$(echo "$1" | awk -F"_" '{print $2}')
|
||||||
|
COLORS="black blue cyan green purple red grey yellow"
|
||||||
|
|
||||||
|
case $color in
|
||||||
|
black) letter="k";;
|
||||||
|
blue) letter="b";;
|
||||||
|
cyan) letter="c";;
|
||||||
|
green) letter="g";;
|
||||||
|
purple) letter="m";;
|
||||||
|
red) letter="r";;
|
||||||
|
grey) letter="w";;
|
||||||
|
yellow) letter="y";;
|
||||||
|
*) letter="w";;
|
||||||
|
esac
|
||||||
|
if [ "$desc" = "light" ]; then
|
||||||
|
letter=$(echo "$letter" | tr "[:lower:]" "[:upper:]")
|
||||||
|
fi
|
||||||
|
echo "$letter"
|
||||||
|
}
|
||||||
|
|
||||||
|
setcolor() {
|
||||||
|
which="$1"
|
||||||
|
color="$2"
|
||||||
|
[ -r $FILE ] && . $FILE
|
||||||
|
if [ "$which" = "foreground" ]; then
|
||||||
|
FOREGROUND=$(getletter "$color")
|
||||||
|
else
|
||||||
|
BACKGROUND=$(getletter "$color")
|
||||||
|
fi
|
||||||
|
printf "FOREGROUND=$FOREGROUND\nBACKGROUND=$BACKGROUND\n" > $FILE
|
||||||
|
touch "/var/run/screen/S-$USER/$PKG.reload-required"
|
||||||
|
}
|
||||||
|
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
prompt
|
prompt "background"
|
||||||
setprofile
|
prompt "foreground"
|
||||||
|
screen -X at 0 source "$HOME/.$PKG/profile"
|
||||||
else
|
else
|
||||||
TEMP=`getopt -o lhs: --long list,help,set: -- "$@"`
|
|
||||||
eval set -- "$TEMP"
|
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-s|--set)
|
-s|--set)
|
||||||
|
@ -157,6 +200,14 @@ else
|
||||||
shift 2
|
shift 2
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
|
-b|--background)
|
||||||
|
setcolor "background" "$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
-f|--foreground)
|
||||||
|
setcolor "foreground" "$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
-l|--list)
|
-l|--list)
|
||||||
listprofiles
|
listprofiles
|
||||||
shift
|
shift
|
||||||
|
@ -171,6 +222,7 @@ else
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
[ $# -eq 0 ] && break
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
2
debian/changelog
vendored
2
debian/changelog
vendored
|
@ -26,6 +26,8 @@ byobu (2.40) unreleased; urgency=low
|
||||||
contrast
|
contrast
|
||||||
* byobu-status: separate COLOR into FOREGROUND and BACKGROUND; more
|
* byobu-status: separate COLOR into FOREGROUND and BACKGROUND; more
|
||||||
flexibility
|
flexibility
|
||||||
|
* byobu-config, byobu-select-profile: rework to independently select
|
||||||
|
background color and foreground color, rather than profile
|
||||||
|
|
||||||
-- Dustin Kirkland <kirkland@ubuntu.com> Tue, 10 Nov 2009 10:18:20 -0600
|
-- Dustin Kirkland <kirkland@ubuntu.com> Tue, 10 Nov 2009 10:18:20 -0600
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue