diff --git a/debian/changelog b/debian/changelog index e24eed51..bf13495a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,12 @@ byobu (4.18) unreleased; urgency=low * usr/bin/byobu, usr/bin/byobu-status: - remove some redundancies + * usr/bin/byobu, usr/bin/byobu-config, usr/bin/byobu-ctrl-a, + usr/bin/byobu-disable, usr/bin/byobu-launcher, usr/bin/byobu-quiet, + usr/bin/byobu-reconnect-sockets, usr/bin/byobu-select-profile, + usr/bin/byobu-select-session, usr/lib/byobu/.constants: + - use a BYOBU_BACKEND environment variable, to support both screen + and tmux -- Dustin Kirkland Wed, 29 Jun 2011 02:26:28 +0000 diff --git a/usr/bin/byobu b/usr/bin/byobu index 58f07576..cb81736f 100755 --- a/usr/bin/byobu +++ b/usr/bin/byobu @@ -1,6 +1,6 @@ #!/bin/sh -e # -# byobu - screen wrapper script +# byobu - wrapper script # Copyright (C) 2008-2009 Canonical Ltd. # # Authors: Dustin Kirkland @@ -28,7 +28,7 @@ if [ "$#" = "1" ]; then case "$1" in -v|--version) echo "$PKG version $VERSION" - exec screen -v + exec $BYOBU_BACKEND -v exit 0 ;; esac @@ -74,7 +74,7 @@ if [ -S "$SSH_AUTH_SOCK" ] && [ ! -h "$SSH_AUTH_SOCK" ]; then ln -sf "$SSH_AUTH_SOCK" "$BYOBU_CONFIG_DIR/.ssh-agent" fi -# Some users want to maintain a separate ~/.byoburc from ~/.screenrc, +# Some users want to maintain separate configurations # if they use both screen and byobu on the same system if [ -r "$HOME/.byoburc" ]; then PROFILE="-c $BYOBU_PREFIX/share/$PKG/profiles/byoburc" @@ -82,16 +82,16 @@ else PROFILE="-c $BYOBU_PREFIX/share/$PKG/profiles/screenrc" fi NAME="-S $PKG" -# Zero out $NAME if user has specified a screen session name +# Zero out $NAME if user has specified a session name for i in "$@"; do case $i in -r|-*S|-ls|-list) NAME= ;; esac done -# Now let's execute screen! +# Now let's execute the backend! if [ "$#" = "0" ]; then - out=$(screen -wipe 2>/dev/null) || true + out=$($BYOBU_BACKEND -wipe 2>/dev/null) || true if [ "$CUSTOM_WINDOW_SET" = "1" ]; then # Start new custom window set session - exec screen $SCREEN_TERM $NAME $PROFILE + exec $BYOBU_BACKEND $SCREEN_TERM $NAME $PROFILE else case "$out" in *\(*\)*) @@ -100,13 +100,13 @@ if [ "$#" = "0" ]; then ;; *) # Start new default session - exec screen $SCREEN_TERM $NAME $PROFILE $DEFAULT_WINDOW + exec $BYOBU_BACKEND $SCREEN_TERM $NAME $PROFILE $DEFAULT_WINDOW ;; esac fi else # Launch with command line args - exec screen $SCREEN_TERM $NAME $PROFILE "$@" + exec $BYOBU_BACKEND $SCREEN_TERM $NAME $PROFILE "$@" fi # vi: syntax=sh ts=4 noexpandtab diff --git a/usr/bin/byobu-config b/usr/bin/byobu-config index 60d4cb53..a19395a1 100755 --- a/usr/bin/byobu-config +++ b/usr/bin/byobu-config @@ -30,6 +30,8 @@ PKG="byobu" HOME=os.getenv("HOME") USER=os.getenv("USER") BYOBU_CONFIG_DIR=os.getenv("BYOBU_CONFIG_DIR") +BYOBU_BACKEND=os.getenv("BYOBU_BACKEND") +SOCKETDIR=os.getenv("SOCKETDIR") if os.getenv("BYOBU_PREFIX"): PREFIX = os.getenv("BYOBU_PREFIX") else: @@ -41,15 +43,9 @@ if not os.path.exists(SHARE): if not os.path.exists(DOC): DOC = BYOBU_CONFIG_DIR+"/"+DOC DEF_ESC="A" -RELOAD = "If you are using the default set of keybindings, press\n or to activate these changes.\n\nOtherwise, exit this screen session and start a new one." -SOCKETDIR="/var/run/screen" -if os.path.exists("/etc/%s/socketdir" % PKG): - try: - execfile(i) - except: - SOCKETDIR="/var/run/screen" +RELOAD = "If you are using the default set of keybindings, press\n or to activate these changes.\n\nOtherwise, exit this session and start a new one." RELOAD_FLAG="%s/reload-required" % (BYOBU_CONFIG_DIR) -RELOAD_CMD="screen -X at 0 source "+BYOBU_CONFIG_DIR+"/profile" +RELOAD_CMD="%s -X at 0 source %s/profile" % (BYOBU_BACKEND, BYOBU_CONFIG_DIR) ESC = '' snack.hotkeys[ESC] = ord(ESC) snack.hotkeys[ord(ESC)] = ESC @@ -96,7 +92,7 @@ def terminal_size(): ### decide on *some* terminal size cr = (25, 80) return int(cr[1]-5), int(cr[0]-5) # reverse rows, cols -def menu(screen, size, isInstalled): +def menu(snackScreen, size, isInstalled): if isInstalled: installtext=_("Byobu currently launches at login (toggle off)") else: @@ -113,9 +109,9 @@ def menu(screen, size, isInstalled): li.append(_("Create new windows"), 7) li.append(_("Manage default windows"), 8) li.append(installtext, 9) - bb = ButtonBar(screen, (("Exit", "exit", ESC),), compact=1) + bb = ButtonBar(snackScreen, (("Exit", "exit", ESC),), compact=1) - g = GridForm(screen, _(" Byobu Configuration Menu"), 1, 2) + g = GridForm(snackScreen, _(" Byobu Configuration Menu"), 1, 2) g.add(li, 0, 0, padding=(4,2,4,2)) g.add(bb, 0, 1, padding=(1,1,0,0)) @@ -124,18 +120,18 @@ def menu(screen, size, isInstalled): else: return li.current() -def messagebox(screen, width, height, title, text, scroll=0, \ +def messagebox(snackScreen, width, height, title, text, scroll=0, \ buttons=((_("Okay"), "okay"),(_("Cancel"), "cancel", ESC)) ): t = Textbox(width, height, text, scroll=scroll ) - bb = ButtonBar(screen, buttons, compact = 1) - g = GridForm(screen, title, 1, 2) + bb = ButtonBar(snackScreen, buttons, compact = 1) + g = GridForm(snackScreen, title, 1, 2) g.add(t, 0, 0, padding=(0,0,0,0)) g.add(bb, 0, 1, padding=(1,1,0,0)) return bb.buttonPressed(g.runOnce()) -def help(screen, size, config): +def help(snackScreen, size, config): f=file(DOC+'/help.txt') text=f.read() f.close() @@ -144,8 +140,8 @@ def help(screen, size, config): text=text.replace("_VER_", commands.getoutput("byobu -v | head -n1 | " + SED + " 's/.* //'"), 1) t = Textbox(70, 14, text, scroll=0) - bb = ButtonBar(screen, ((_("Menu"), "menu", ESC),), compact = 1) - g = GridForm(screen, _("Byobu Help"), 1, 3) + bb = ButtonBar(snackScreen, ((_("Menu"), "menu", ESC),), compact = 1) + g = GridForm(snackScreen, _("Byobu Help"), 1, 3) g.add(t, 0, 0, padding=(0,0,0,0)) g.add(bb, 0, 2, padding=(1,1,0,0)) @@ -153,18 +149,18 @@ def help(screen, size, config): return 100 -def select_color(screen, size, layer): +def select_color(snackScreen, size, layer): li = Listbox(height = 8, width = 60, scroll = 1, returnExit = 1) for choice in commands.getoutput('byobu-select-profile -l').splitlines(): li.append(choice, choice) - bb = ButtonBar(screen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact = 1) + bb = ButtonBar(snackScreen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact = 1) if layer == "foreground": - g = GridForm(screen, _("Choose a foreground color:"), 1, 2) + g = GridForm(snackScreen, _("Choose a foreground color:"), 1, 2) else: - g = GridForm(screen, _("Choose a background color:"), 1, 2) + g = GridForm(snackScreen, _("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)) @@ -177,14 +173,14 @@ def select_color(screen, size, layer): reload_required() return 100 -def keybindings(screen, size): +def keybindings(snackScreen, size): li = Listbox(height = 6, width = 60, returnExit = 1) for choice in commands.getoutput('ls '+SHARE+'/keybindings').splitlines(): if choice != "common" and choice != "none": li.append(choice, choice) li.append("none", "none") - bb = ButtonBar(screen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact = 1) - g = GridForm(screen, _("Which set of keybindings would you like to use?"), 1, 2) + bb = ButtonBar(snackScreen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact = 1) + g = GridForm(snackScreen, _("Which set of keybindings would you like to use?"), 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": @@ -195,7 +191,7 @@ def keybindings(screen, size): def switch_keybindings(set): commands.getoutput(SED + " -i -e 's:^source .*$:source "+SHARE+"/keybindings/"+set+":' "+BYOBU_CONFIG_DIR+"/keybindings") -def newwindow(screen, size): +def newwindow(snackScreen, size): title=Entry(8, text="shell", returnExit=1) titlel=Label(_("Title: ")) command=Entry(20, text="/bin/sh", returnExit=1) @@ -219,9 +215,9 @@ def newwindow(screen, size): cb=Checkbox(_("Add to default windows")) - bb = ButtonBar(screen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact = 1) + bb = ButtonBar(snackScreen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact = 1) - g = GridForm(screen, _("Create new window(s):"), 2, 6 ) + g = GridForm(snackScreen, _("Create new window(s):"), 2, 6 ) g.add(titlel, 0, 0, anchorLeft=1,padding=(4,1,0,1)) g.add(title, 1, 0, anchorLeft=1) g.add(commandl, 0, 1, anchorLeft=1, anchorTop=1,padding=(4,0,0,1)) @@ -237,18 +233,18 @@ def newwindow(screen, size): sel=r.getSelection() if sel: for s in sel: - win='screen -t %s %s' % (cmd[s][1], cmd[s][2]) + win='%s -t %s %s' % (BYOBU_BACKEND, cmd[s][1], cmd[s][2]) commands.getoutput(win) if cb.value(): appendwindow(win) else: - cpath='screen -X setenv newpath %s' % (path.value()) - win='screen -X eval \'chdir $newpath\' \"screen -t %s %s\"' % (title.value(), command.value()) + cpath='%s -X setenv newpath %s' % (BYOBU_BACKEND, path.value()) + win='%s -X eval \'chdir $newpath\' \"%s -t %s %s\"' % (BYOBU_BACKEND, BYOBU_BACKEND, title.value(), command.value()) commands.getoutput(cpath) commands.getoutput(win) if cb.value(): cpath='chdir %s' % (path.value()) - win='screen -t %s %s' % (title.value(), command.value()) + win='%s -t %s %s' % (BYOBU_BACKEND, title.value(), command.value()) appendwindow(cpath) appendwindow(win) @@ -365,7 +361,7 @@ def writestatus(items): return None f.close() -def togglestatus(screen, size): +def togglestatus(snackScreen, size): itemlist=readstatus() rl=Label("") r=CheckboxTree(12, scroll=1) @@ -374,8 +370,8 @@ def togglestatus(screen, size): if item[0] != -1: r.append(item[1],count,selected=item[0]) count=count+1 - bb = ButtonBar(screen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact = 1) - g = GridForm(screen, _("Toggle status notifications:"), 2, 4 ) + bb = ButtonBar(snackScreen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact = 1) + g = GridForm(snackScreen, _("Toggle status notifications:"), 2, 4 ) g.add(rl, 0, 0, anchorLeft=1, anchorTop=1, padding=(4,0,0,1)) g.add(r, 1, 0) g.add(bb, 1, 1, padding=(4,1,0,0)) @@ -404,7 +400,7 @@ def writewindows(winlist): return None f.close() -def defaultwindows(screen, size): +def defaultwindows(snackScreen, size): winlist=readwindows() rl=Label(_("Windows:")) @@ -415,9 +411,9 @@ def defaultwindows(screen, size): r.append(win[1],count,selected=win[0]) count=count+1 - bb = ButtonBar(screen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact = 1) + bb = ButtonBar(snackScreen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact = 1) - g = GridForm(screen, _("Select window(s) to create by default:"), 2, 4 ) + g = GridForm(snackScreen, _("Select window(s) to create by default:"), 2, 4 ) g.add(rl, 0, 0, anchorLeft=1, anchorTop=1, padding=(4,0,0,1)) g.add(r, 1, 0) g.add(bb, 1, 1, padding=(4,1,0,0)) @@ -433,18 +429,18 @@ def defaultwindows(screen, size): return 100 -def install(screen, size, isInstalled): +def install(snackScreen, size, isInstalled): if isInstalled: out = commands.getoutput("byobu-launcher-uninstall") if out == "": out = _("Byobu will not be used next time you login.") - button = messagebox(screen, 60, 2, _("Message"), out, buttons=((_("Menu"), ))) + button = messagebox(snackScreen, 60, 2, _("Message"), out, buttons=((_("Menu"), ))) return 101 else: out = commands.getoutput("byobu-launcher-install") if out == "": out = _("Byobu will be launched automatically next time you login.") - button = messagebox(screen, 60, 2, "Message", out, buttons=((_("Menu"), ))) + button = messagebox(snackScreen, 60, 2, "Message", out, buttons=((_("Menu"), ))) return 100 def appendtofile(p, s): @@ -486,12 +482,12 @@ def setesckey(key): out = commands.getoutput(SED+" -i -e 's/\"^^/\"\^"+l+"/g' "+path) out = commands.getoutput(SED+" -i -e '/^$/d' "+path) -def chgesc(screen, size): +def chgesc(snackScreen, size): esc=Entry(2, text=getesckey(), returnExit=1) escl=Label(_("Escape key: ctrl-")) - bb = ButtonBar(screen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact = 1) + bb = ButtonBar(snackScreen, ((_("Apply"), "apply"), (_("Cancel"), "cancel", ESC)), compact = 1) - g = GridForm(screen, _("Change escape sequence:"), 2, 4 ) + g = GridForm(snackScreen, _("Change escape sequence:"), 2, 4 ) g.add(escl, 0, 0, anchorLeft=1, padding=(1,0,0,1)) g.add(esc, 1, 0, anchorLeft=1) g.add(bb, 1, 1) @@ -515,7 +511,7 @@ def chgesc(screen, size): dummy = "foo" else: loop=0 - screen.popWindow() + snackScreen.popWindow() button = bb.buttonPressed(which) if button != "cancel": setesckey(esc.value()) @@ -539,9 +535,9 @@ def main(): """ size = terminal_size() - screen = SnackScreen() - screen.drawRootText(1,0,_(' Byobu Configuration Menu')) - screen.pushHelpLine(_('/ between elements | selects | exits')) + snackScreen = SnackScreen() + snackScreen.drawRootText(1,0,_(' Byobu Configuration Menu')) + snackScreen.pushHelpLine(_('/ between elements | selects | exits')) config = SafeConfigParser() @@ -550,28 +546,28 @@ def main(): tag = 100 while tag > 0 : - tag = menu(screen, size, isInstalled) + tag = menu(snackScreen, size, isInstalled) if tag == 1: - tag = help(screen, size, config) + tag = help(snackScreen, size, config) elif tag == 2: - tag = select_color(screen, size, "background") + tag = select_color(snackScreen, size, "background") elif tag == 3: - tag = select_color(screen, size, "foreground") + tag = select_color(snackScreen, size, "foreground") elif tag == 4: - tag = togglestatus(screen, size) + tag = togglestatus(snackScreen, size) elif tag == 5: - tag = keybindings(screen, size) + tag = keybindings(snackScreen, size) elif tag == 6: - tag = chgesc(screen, size) + tag = chgesc(snackScreen, size) elif tag == 7: - tag = newwindow(screen, size) + tag = newwindow(snackScreen, size) elif tag == 8: - tag = defaultwindows(screen, size) + tag = defaultwindows(snackScreen, size) elif tag == 9: - tag = install(screen, size, isInstalled) + tag = install(snackScreen, size, isInstalled) isInstalled = autolaunch() - screen.finish() + snackScreen.finish() sys.exit(0) diff --git a/usr/bin/byobu-ctrl-a b/usr/bin/byobu-ctrl-a index fb704211..e454926a 100755 --- a/usr/bin/byobu-ctrl-a +++ b/usr/bin/byobu-ctrl-a @@ -30,7 +30,7 @@ while true; do echo echo "When you press ctrl-a in Byobu, do you want it to operate in:" echo " (1) Emacs mode (go to beginning of line)" - echo " (2) Screen mode (screen's default escape sequence)" + echo " (2) Screen mode (GNU Screen's default escape sequence)" echo echo "Note that:" echo " - F12 also operates as Screen escape in Byobu" @@ -52,12 +52,12 @@ while true; do echo 'escape "^Aa"' >> "$keybindings" echo 'register x "^A"' >> "$keybindings" echo 'bindkey "^A"' >> "$keybindings" - echo "INFO: ctrl-a will now operate in screen mode" + echo "INFO: ctrl-a will now operate in GNU Screen mode" break ;; esac done -screen -X at 0 source "$BYOBU_CONFIG_DIR/profile" +$BYOBU_BACKEND -X at 0 source "$BYOBU_CONFIG_DIR/profile" echo "To modify this behavior again later, run 'byobu-ctrl-a'" echo diff --git a/usr/bin/byobu-disable b/usr/bin/byobu-disable index 733cab32..df2537ec 100755 --- a/usr/bin/byobu-disable +++ b/usr/bin/byobu-disable @@ -33,7 +33,7 @@ echo # If we're in a byobu session, let's exit that too case "$STY" in *byobu) - screen -X at 0 quit + $BYOBU_BACKEND -X at 0 quit ;; esac diff --git a/usr/bin/byobu-launcher b/usr/bin/byobu-launcher index 9b10fb35..963ecc55 100755 --- a/usr/bin/byobu-launcher +++ b/usr/bin/byobu-launcher @@ -27,7 +27,7 @@ else case "$TERM" in *screen*) # Handle nesting - printf "$(gettext 'To launch in a nested screen session, run: byobu')\n" + printf "$(gettext 'To launch in a nested session, run: byobu')\n" ;; dumb) # Dumb terminal, don't launch diff --git a/usr/bin/byobu-quiet b/usr/bin/byobu-quiet index 8acdd239..30d9f9b9 100755 --- a/usr/bin/byobu-quiet +++ b/usr/bin/byobu-quiet @@ -33,6 +33,6 @@ else status="$USER@$(hostname)" echo "hardstatus lastline '$status'" >> "$BYOBU_CONFIG_DIR/keybindings" fi -screen -X at 0 source "$BYOBU_CONFIG_DIR/profile" +$BYOBU_BACKEND -X at 0 source "$BYOBU_CONFIG_DIR/profile" # vi: syntax=sh ts=4 noexpandtab diff --git a/usr/bin/byobu-reconnect-sockets b/usr/bin/byobu-reconnect-sockets index de6b763f..2775e10d 100755 --- a/usr/bin/byobu-reconnect-sockets +++ b/usr/bin/byobu-reconnect-sockets @@ -30,7 +30,6 @@ case "$-" in # no-op ;; *) - # screen -X -S "$PKG" at "$USER*" stuff ". $0"; then echo 2>&1 echo "ERROR: You must source this file, rather than execute it." 2>&1 echo " . $0" 2>&1 diff --git a/usr/bin/byobu-select-profile b/usr/bin/byobu-select-profile index 57c814d6..65711359 100755 --- a/usr/bin/byobu-select-profile +++ b/usr/bin/byobu-select-profile @@ -182,7 +182,7 @@ setcolor() { if [ $# -eq 0 ]; then prompt "background" prompt "foreground" - screen -X at 0 source "$BYOBU_CONFIG_DIR/profile" + $BYOBU_BACKEND -X at 0 source "$BYOBU_CONFIG_DIR/profile" else while true; do case "$1" in diff --git a/usr/bin/byobu-select-session b/usr/bin/byobu-select-session index f59438d3..3cdb1419 100755 --- a/usr/bin/byobu-select-session +++ b/usr/bin/byobu-select-session @@ -24,12 +24,13 @@ PKG = "byobu" SHELL = os.getenv("SHELL", "/bin/bash") HOME=os.getenv("HOME") BYOBU_CONFIG_DIR=os.getenv("BYOBU_CONFIG_DIR") +BYOBU_BACKEND=os.getenv("BYOBU_BACKEND") choice = "" sessions = [] text = [] i = 0 -output = commands.getoutput('screen -ls ') +output = commands.getoutput('%s -ls ', BYOBU_BACKEND) if output: for s in output.split("\n"): s = re.sub(r'\s+', ' ', s) @@ -74,8 +75,8 @@ if len(sessions) > 1: choice = "" sys.stderr.write("\nERROR: Invalid input\n"); elif len(sessions) == 1: - # Attach to the chosen session; must use the 'screen' binary - os.execvp("screen", ["", "-AOxRR"]) + # Attach to the chosen session; must use the binary, not the wrapper! + os.execvp(BYOBU_BACKEND, ["", "-AOxRR"]) if choice: if sessions[choice-1] == "NEW": @@ -84,8 +85,8 @@ if choice: elif sessions[choice-1] == "SHELL": os.execvp(SHELL, [SHELL]) else: - # Attach to the chosen session; must use the 'screen' binary - os.execvp("screen", ["", "-AOxRR", sessions[choice-1]]) + # Attach to the chosen session; must use the binary, not the wrapper! + os.execvp(BYOBU_BACKEND, ["", "-AOxRR", sessions[choice-1]]) # No valid selection, default to the youngest session, create if necessary os.execvp("byobu", ["", "-AOxRR"]) diff --git a/usr/lib/byobu/.constants b/usr/lib/byobu/.constants index e13302a7..34ff9b9a 100755 --- a/usr/lib/byobu/.constants +++ b/usr/lib/byobu/.constants @@ -20,6 +20,9 @@ PKG="byobu" +# Support two different backends (screen/tmux) +[ -z "$BYOBU_BACKEND" ] && export BYOBU_BACKEND="screen" || export BYOBU_BACKEND + # Create and set the user configuration directory if [ -d "$XDG_CONFIG_HOME" ] && mkdir -p "$XDG_CONFIG_HOME/$PKG"; then export BYOBU_CONFIG_DIR="$XDG_CONFIG_HOME/$PKG"