From a71fa39e26b46e7c87bc56d9151500f321aa1cd0 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Tue, 4 May 2010 12:54:56 -0500 Subject: [PATCH] usr/bin/byobu: add support for different window sets, LP: #517796 --- debian/changelog | 3 +-- usr/bin/byobu | 45 +++++++++++++++++++++----------- usr/bin/byobu-janitor | 1 - usr/share/byobu/profiles/byoburc | 1 - 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/debian/changelog b/debian/changelog index 8afe1ef2..1c41efb9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,8 +2,7 @@ byobu (2.74) unreleased; urgency=low * usr/lib/byobu/disk_io: fix regex to support RAID devices, LP: #572855 * debian/postinst: make debconf question failsafe, LP: #569041 - * bin/byobu, bin/byobu-janitor, share/byobu/profiles/byoburc: add support - for different window sets, LP: #517796 + * usr/bin/byobu: add support for different window sets, LP: #517796 -- Dustin Kirkland Wed, 28 Apr 2010 23:11:14 -0500 diff --git a/usr/bin/byobu b/usr/bin/byobu index 254470c1..4b0bdcaa 100755 --- a/usr/bin/byobu +++ b/usr/bin/byobu @@ -20,15 +20,27 @@ PKG="byobu" VERSION=2.74 -# Add a version argument for debugging purposes -if [ "$#" = "1" ] && [ "$1" = "-v" ]; then - echo "$PKG version $VERSION" - screen -v - exit 0 -fi +while [ ! -z "$1" ]; do + case "$1" in + -v|--version) + echo "$PKG version $VERSION" + screen -v + exit 0 + ;; + --windows) + if [ -r "$2" ]; then + WINDOWS=$(cat "$2") + fi + shift 2 + ;; + *) + ARGS="$ARGS $1" + ;; + esac +done # Check if we're being autolaunched, and this user explicitly does not want it. -if [ "$0" = "/etc/profile.d/$PKG.sh" ] && [ -r "$HOME/.$PKG/disable-autolaunch" ]; then +if [ "$0" = "/etc/profile.d/Z98-$PKG.sh" ] && [ -r "$HOME/.$PKG/disable-autolaunch" ]; then exit 0 fi @@ -38,8 +50,15 @@ byobu-janitor --force # Set window title until https://bugs.launchpad.net/bugs/338722 is fixed in screen printf "\033]0;${USER}@$(hostname) - ${PKG}\007" -# Launch motd+shell, unless the user has default windows set to launch -grep -qs "^[^#]" "$HOME/.$PKG/windows" && DEFAULT_WINDOW= || DEFAULT_WINDOW="motd+shell" +# Configure default windows +DEFAULT_WINDOW= +if [ -n "$WINDOWS" ]; + mv -f "$HOME/.byobu/windows" "$HOME/.byobu/.windows-swap" + cleanup='mv -f "$HOME/.byobu/.windows-swap" "$HOME/.byobu/windows"' + printf "%s\n%s\n" "$WINDOWS\n" "$cleanup" > "$HOME/.byobu/windows" +elif ! grep -qs "^[^#]" "$HOME/.$PKG/windows"; then + DEFAULT_WINDOW="-t shell motd+shell" +fi # Check if our terminfo supports 256 colors [ -x /usr/bin/tput ] && [ $(/usr/bin/tput colors 2>/dev/null || echo 0) -eq 256 ] && SCREEN_TERM="-T screen-256color" @@ -58,13 +77,9 @@ if [ "$#" = "0" ]; then else NO_SOCKETS="^No Sockets found in " fi - if [ -s "$BYOBU_WINDOWS" ]; then - # Launch with custom window set - cat "$BYOBU_WINDOWS" > "$HOME/.$PKG/.windows-tmp" - exec screen $SCREEN_TERM -c "/usr/share/$PKG/profiles/byoburc" - elif echo "$out" | LANG=C grep -qsi "$NO_SOCKETS"; then + if echo "$out" | LANG=C grep -qsi "$NO_SOCKETS"; then # Start new session - exec screen $SCREEN_TERM -c "/usr/share/$PKG/profiles/byoburc" -t shell $DEFAULT_WINDOW + exec screen $SCREEN_TERM -c "/usr/share/$PKG/profiles/byoburc" $DEFAULT_WINDOW else # Select and attach to an existing session exec byobu-select-session diff --git a/usr/bin/byobu-janitor b/usr/bin/byobu-janitor index 039f47d2..618b174b 100755 --- a/usr/bin/byobu-janitor +++ b/usr/bin/byobu-janitor @@ -23,7 +23,6 @@ PKG="byobu" [ -r "/etc/$PKG/socketdir" ] && . "/etc/$PKG/socketdir" || SOCKETDIR="/var/run/screen" RUN="$SOCKETDIR/S-$USER" FLAG="$RUN/$PKG.reload-required" -echo > "$HOME/.$PKG/.windows-tmp" # Exit immediately, if we're not forced, and there is no reload flag if [ "$1" != "--force" ] && [ ! -e "$FLAG" ]; then diff --git a/usr/share/byobu/profiles/byoburc b/usr/share/byobu/profiles/byoburc index 9530ff44..09437bdc 100644 --- a/usr/share/byobu/profiles/byoburc +++ b/usr/share/byobu/profiles/byoburc @@ -21,5 +21,4 @@ source $HOME/.byobu/profile source $HOME/.byobu/windows -source $HOME/.byobu/.windows-tmp source $HOME/.screenrc