From 091b1c403ad734f597536033208842312c4994e2 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Mon, 14 Jan 2013 15:15:42 -0600 Subject: [PATCH] * usr/bin/byobu-select-profile: LP: #946112 - fix byobu interactive color selection in tmux --- debian/changelog | 2 ++ usr/bin/byobu-select-profile | 28 +++++++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/debian/changelog b/debian/changelog index 2e1b9694..877f24f3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,8 @@ byobu (5.27) unreleased; urgency=low usr/bin/byobu-tmux, === target is byobu: LP: #1022882 - add symlinks to repo, makes it easier to use byobu straight out of bzr + * usr/bin/byobu-select-profile: LP: #946112 + - fix byobu interactive color selection in tmux -- Dustin Kirkland Thu, 10 Jan 2013 16:36:23 -0600 diff --git a/usr/bin/byobu-select-profile b/usr/bin/byobu-select-profile index 5a5df547..7268aa45 100755 --- a/usr/bin/byobu-select-profile +++ b/usr/bin/byobu-select-profile @@ -116,7 +116,14 @@ prompt() { i=$(expr $i + 1) done echo `gettext "Selected"` "$which [$color]" - setcolor "$which" "$color" + case "$BYOBU_BACKEND" in + screen) + setcolor_screen "$which" "$color" + ;; + tmux|*) + setcolor_tmux "$color" + ;; + esac return 0 fi done @@ -154,7 +161,7 @@ getletter() { echo "$letter" } -setcolor() { +setcolor_screen() { which="$1" color="$2" [ -r $FILE ] && . $FILE @@ -166,6 +173,7 @@ setcolor() { [ "$MONOCHROME" = "1" ] || MONOCHROME=0 printf "FOREGROUND=$FOREGROUND\nBACKGROUND=$BACKGROUND\nMONOCHROME=$MONOCHROME" > $FILE touch "$BYOBU_RUN_DIR/reload-required" + $BYOBU_BACKEND -X at 0 source "$BYOBU_CONFIG_DIR/profile" } get_contrast() { @@ -180,29 +188,35 @@ get_contrast() { } setcolor_tmux() { + if [ "$BYOBU_BACKEND" != "tmux" ]; then + echo "WARNING: This functionality is only supported in Byobu with the tmux backend" 1>&2 + fi dark="$1" get_contrast "$dark" light="$_RET" accent="magenta" highlight="red" monochrome="0" - printf "BYOBU_DARK=\"#$dark\"\nBYOBU_LIGHT=$light\nBYOBU_ACCENT=$accent\nBYOBU_HIGHLIGHT=$highlight\nMONOCHROME=$MONOCHROME" > "$FILE".tmux + printf "BYOBU_DARK=\"$dark\"\nBYOBU_LIGHT=$light\nBYOBU_ACCENT=$accent\nBYOBU_HIGHLIGHT=$highlight\nMONOCHROME=$MONOCHROME" > "$FILE".tmux tmux source "$BYOBU_PREFIX/share/byobu/profiles/tmuxrc" } if [ $# -eq 0 ]; then prompt "background" - prompt "foreground" - $BYOBU_BACKEND -X at 0 source "$BYOBU_CONFIG_DIR/profile" + case "$BYOBU_BACKEND" in + screen) + prompt "foreground" + ;; + esac else while true; do case "$1" in -b|--background) - setcolor "background" "$2" + setcolor_screen "background" "$2" shift 2 ;; -f|--foreground) - setcolor "foreground" "$2" + setcolor_screen "foreground" "$2" shift 2 ;; -l|--list)