From 2f4608544a5d10dbe339dd8ffd93d9f96850cd8d Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Sun, 15 Jan 2012 13:29:00 -0600 Subject: [PATCH] * usr/bin/byobu, usr/bin/byobu-janitor, usr/lib/byobu/include/common, usr/lib/byobu/include/constants: - for users upgrading from an older version of byobu, where they were previously using a screen backend, keep them using a screen backend - for new users, default to tmux backend --- debian/changelog | 5 +++++ usr/bin/byobu | 12 ++++++------ usr/bin/byobu-janitor | 1 + usr/lib/byobu/include/common | 20 +++++++++++++++----- usr/lib/byobu/include/constants | 2 +- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/debian/changelog b/debian/changelog index fe6f8adc..8ced1c45 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,6 +26,11 @@ byobu (5.3) unreleased; urgency=low - support LC_TERMTYPE=[byobu|byobu-screen|byobu-tmux] * etc/profile.d/Z97-byobu.sh, usr/bin/byobu-launcher: LP: #897711 - allow nesting, if LC_BYOBU > 1 + * usr/bin/byobu, usr/bin/byobu-janitor, usr/lib/byobu/include/common, + usr/lib/byobu/include/constants: + - for users upgrading from an older version of byobu, where they were + previously using a screen backend, keep them using a screen backend + - for new users, default to tmux backend [ Dustin Kirkland and Ryan Thompson ] * usr/bin/byobu-reconnect-sockets, usr/bin/byobu-select-session: LP: #908944 diff --git a/usr/bin/byobu b/usr/bin/byobu index 6200cbc2..c4c10f86 100755 --- a/usr/bin/byobu +++ b/usr/bin/byobu @@ -31,12 +31,6 @@ if [ ! -O "$HOME" ]; then exit 1 fi -# Determine backend as early as possible, if applicable -case "$0" in - *byobu-screen) BYOBU_BACKEND="screen" ;; - *byobu-tmux) BYOBU_BACKEND="tmux" ;; -esac - # Source local byobu config if [ -r "$HOME/.byoburc" ]; then # Ensure that this configuration is usable @@ -55,6 +49,12 @@ fi [ -z "${BYOBU_PREFIX}" ] && export BYOBU_PREFIX="/usr" || export BYOBU_PREFIX . "${BYOBU_PREFIX}/lib/${PKG}/include/common" +# Override backend if we can determine intentions from argv[0] +case "$0" in + *byobu-screen) BYOBU_BACKEND="screen" ;; + *byobu-tmux) BYOBU_BACKEND="tmux" ;; +esac + # At this point, we're sure BYOBU_BACKEND is properly defined export BYOBU_BACKEND diff --git a/usr/bin/byobu-janitor b/usr/bin/byobu-janitor index 36dee497..1846dbfd 100755 --- a/usr/bin/byobu-janitor +++ b/usr/bin/byobu-janitor @@ -68,6 +68,7 @@ MC=0 [ -r "$BYOBU_CONFIG_DIR/profile.tmux" ] || echo "source \$BYOBU_PREFIX/share/$PKG/profiles/tmux" > "$BYOBU_CONFIG_DIR/profile.tmux" [ -r "$BYOBU_CONFIG_DIR/keybindings" ] || echo "source \$BYOBU_PREFIX/share/$PKG/keybindings/common" > "$BYOBU_CONFIG_DIR/keybindings" [ -r "$BYOBU_CONFIG_DIR/windows" ] || touch "$BYOBU_CONFIG_DIR/windows" +[ -r "$BYOBU_CONFIG_DIR/backend" ] || echo "BYOBU_BACKEND=$BYOBU_BACKEND" > "$BYOBU_CONFIG_DIR/backend" [ -r "$HOME/.screenrc" ] || touch "$HOME/.screenrc" [ -r "$BYOBU_CONFIG_DIR/.tmux.conf" ] || touch "$BYOBU_CONFIG_DIR/.tmux.conf" for f in status statusrc; do diff --git a/usr/lib/byobu/include/common b/usr/lib/byobu/include/common index d6ade629..9483f3bf 100755 --- a/usr/lib/byobu/include/common +++ b/usr/lib/byobu/include/common @@ -28,12 +28,22 @@ if [ -z "${BYOBU_INCLUDED_LIBS}" ]; then [ -r "$BYOBU_CONFIG_DIR/backend" ] && . "$BYOBU_CONFIG_DIR/backend" # Just in case there's no config file at all if [ -z "${BYOBU_BACKEND}" ]; then - # If tmux is installed, use it - if command -v tmux >/dev/null; then - BYOBU_BACKEND=tmux - elif command -v screen >/dev/null; then - BYOBU_BACKEND=screen + if [ -d "$BYOBU_CONFIG_DIR" ] && [ -r "$BYOBU_CONFIG_DIR/profile" ]; then + # Previous byobu configuration exists, default to screen + for i in screen tmux; do + command -v $i >/dev/null && BYOBU_BACKEND="$i" + break + done + unset i else + # New byobu configuration, default to tmux + for i in tmux screen; do + command -v $i >/dev/null && BYOBU_BACKEND="$i" + break + done + unset i + fi + if ! command -v "$BYOBU_BACKEND" >/dev/null; then echo "ERROR: $PKG won't work without tmux or screen installed" 1>&2 fi fi diff --git a/usr/lib/byobu/include/constants b/usr/lib/byobu/include/constants index 9c6f8571..8d70bc6e 100755 --- a/usr/lib/byobu/include/constants +++ b/usr/lib/byobu/include/constants @@ -86,7 +86,7 @@ case "$BYOBU_BACKEND" in BYOBU_ARG_VERSION="-V" ESC= ;; - *) + screen) export BYOBU_BACKEND="screen" BYOBU_ARG_VERSION="-v" ESC="\005"