diff --git a/byobu-config b/byobu-config index 2eedbea7..3debed35 100755 --- a/byobu-config +++ b/byobu-config @@ -85,15 +85,16 @@ def menu(screen, size, isInstalled): 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(_("Change Byobu's colors"), 2) - li.append(_("Toggle status notifications"), 3) - li.append(_("Change keybinding set"), 4) - li.append(_("Change escape sequence"), 5) - li.append(_("Create new windows"), 6) - li.append(_("Manage default windows"), 7) - li.append(installtext, 8) + li.append(_("Change Byobu's background color"), 2) + li.append(_("Change Byobu's foreground color"), 3) + li.append(_("Toggle status notifications"), 4) + li.append(_("Change keybinding set"), 5) + li.append(_("Change escape sequence"), 6) + li.append(_("Create new windows"), 7) + li.append(_("Manage default windows"), 8) + li.append(installtext, 9) bb = ButtonBar(screen, (("Exit", "exit", ESC),), compact=1) g = GridForm(screen, _(" Byobu Configuration Menu"), 1, 2) @@ -135,7 +136,7 @@ def help(screen, size, config): return 100 -def profile(screen, size): +def select_color(screen, size, layer): li = Listbox(height = 8, width = 60, scroll = 1, returnExit = 1) 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) - 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(bb, 0, 1, padding=(1,1,0,0)) 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() return 100 @@ -498,18 +507,20 @@ def main(): if tag == 1: tag = help(screen, size, config) elif tag == 2: - tag = profile(screen, size) + tag = select_color(screen, size, "background") elif tag == 3: - tag = togglestatus(screen, size) + tag = select_color(screen, size, "foreground") elif tag == 4: + tag = togglestatus(screen, size) + elif tag == 5: tag = keybindings(screen, size) - elif tag == 5: + elif tag == 6: tag = chgesc(screen, size) - elif tag == 6: - tag = newwindow(screen, size) elif tag == 7: - tag = defaultwindows(screen, size) + tag = newwindow(screen, size) elif tag == 8: + tag = defaultwindows(screen, size) + elif tag == 9: tag = install(screen, size, isInstalled) isInstalled=(tag == 100) diff --git a/byobu-select-profile b/byobu-select-profile index 005a7699..f3c7a9f6 100755 --- a/byobu-select-profile +++ b/byobu-select-profile @@ -26,6 +26,8 @@ PKG="byobu" TEXTDOMAIN="$PKG" +COLORS="black blue cyan green purple red grey yellow" + usage () { cat </dev/null) 2>/dev/null - basename $(ls $PROFILE_DIR/light 2>/dev/null) 2>/dev/null - 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" + for x in $COLORS; do + echo "dark_$x" + echo "light_$x" done } prompt() { - # Prompt the user to choose among the available profiles - 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 + which="$1" count=1 + selected=-1 while /bin/true; do if [ $count -gt 5 ]; then echo `gettext "ERROR: Invalid selection"` exit 1 fi - count=`expr $count + 1` - if [ -z "$selected" -a ! -z "$simple" ]; then + count=$(expr $count + 1) + 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" elif ! test $selected -gt 0 2>/dev/null; then echo -n "`gettext 'Choose'` 1-$i [$simple]: " @@ -107,10 +106,20 @@ prompt() { echo -n "`gettext 'Choose'` 1-$i [$simple]: " selected=`head -n1` 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 done - SELECTED="$selected" } setprofile() { @@ -144,12 +153,46 @@ setprofile() { 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 - prompt - setprofile + prompt "background" + prompt "foreground" + screen -X at 0 source "$HOME/.$PKG/profile" else - TEMP=`getopt -o lhs: --long list,help,set: -- "$@"` - eval set -- "$TEMP" while true; do case "$1" in -s|--set) @@ -157,6 +200,14 @@ else shift 2 break ;; + -b|--background) + setcolor "background" "$2" + shift 2 + ;; + -f|--foreground) + setcolor "foreground" "$2" + shift 2 + ;; -l|--list) listprofiles shift @@ -171,6 +222,7 @@ else break ;; esac + [ $# -eq 0 ] && break done fi diff --git a/debian/changelog b/debian/changelog index e7b9df42..2667e0c4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,6 +26,8 @@ byobu (2.40) unreleased; urgency=low contrast * byobu-status: separate COLOR into FOREGROUND and BACKGROUND; more flexibility + * byobu-config, byobu-select-profile: rework to independently select + background color and foreground color, rather than profile -- Dustin Kirkland Tue, 10 Nov 2009 10:18:20 -0600