Menu

how to automate: one new window with multiple named tabs

Help
Tom Roche
2015-08-05
2015-08-08
  • Tom Roche

    Tom Roche - 2015-08-05

    summary: Please provide script or profile or whatever that automates the following simple result: create a new ROXTerm window containing 3 tabs, each named 'foo', 'bar', and 'baz'. If this is not currently possible, please lemme know. Failed attempts listed below.

    details:

    I'm another former gnome-terminal user who updated debian to jessie and discovered he could no longer change his tab titles. After reading online, I decided to try ROXTerm. I immediately liked ROXTerm more when I discovered that S-C-Q put up a dialog, rather than just killing my terminal window: that's something (IIRC) the gnome-terminal folks have refused to implement, even as an option.

    I'd like ROXTerm better even better if I could do something that seems straightforward, and which several posts in this forum seem to claim (IIUC, which I may not) to be able to do: automate creation of a new window with several tabs, and name each tab. The usecase here is to create something (script? profile?) that I can put on several boxes, such that, when I login, I get a terminal window prepopulated with those named tabs. Here's what I've tried:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    #!/usr/bin/env bash
    ### ROXTerm-setup.sh : setup a ROXTerm window
    
    PROFILE_DIR="${HOME}/.config/roxterm.sourceforge.net/Profiles"
    WINDOW_NAME='ROXTerm'
    
    function show_profile {
      local PROFILE_FP="${PROFILE_DIR}/${PROFILE_NAME}"
      echo -e "profile='${PROFILE_FP}' :"
      cat ${PROFILE_FP}
      echo # newline
    }
    

    The above header is used in all following versions of ROXTerm-setup.sh. Profile=Default is that which normally installs, at least with the roxterm version=2.9.5 currently (as of 5 Aug 2015) in debian version=8/jessie. If I follow that header with the following bash code

    PROFILE_NAME='Default'
    show_profile
    roxterm --profile ${PROFILE_NAME} --title ${WINDOW_NAME} --fork --tab -n 'foo' --tab -n 'bar' --tab -n 'baz'
    

    I get: 1 window with one tab, tabname=baz. I.e., the window title is correct, but the tab title is not correct. To be specific, on exit from script (or whatever) I want to see 1 and only 1 terminal window. To be a bit more specific, and using 1-based indexing because that's how ROXTerm numbers its tabs, what I want is

    window[1]: windowname='ROXTerm', tabname[1]=='foo', tabname[2]=='bar', tabname[3]=='baz'

    and no other windows (or tabs). After reading a bit more, it seemed I would never be able to create more than one initial tab; instead, I would need to create a profile to do that. So I did

    $ pushd /home/me/.config/roxterm.sourceforge.net/Profiles/
    $ sed -e 's/1/3/g' < ./Default > ./profile_with_3_init_tabs
    $ cat ./profile_with_3_init_tabs 
    [roxterm profile]
    colour_scheme=
    init_tabs=3
    

    and I changed the code in my script=ROXTerm-setup.sh to do (after the header)

    PROFILE_NAME='profile_with_3_init_tabs'
    show_profile
    roxterm --profile ${PROFILE_NAME} --title ${WINDOW_NAME} --fork --tab -n 'foo' --tab -n 'bar' --tab -n 'baz'
    

    Result: 1 window with 3 tabs, tabname[1]=='baz', tabname[2,3]==default. So apparently only the first tab is getting its name (over)written. So I tried following the header above with the following bash code:

    PROFILE_NAME='profile_with_3_init_tabs'
    show_profile
    roxterm --profile ${PROFILE_NAME} --title ${WINDOW_NAME} --fork
    roxterm --profile ${PROFILE_NAME} --fork --tab -n 'foo'
    roxterm --profile ${PROFILE_NAME} --fork --tab -n 'bar'
    roxterm --profile ${PROFILE_NAME} --fork --tab -n 'baz'
    

    The result, at end of script, is 4 separate windows (simultaneously showing), each with 3 tabs:

    window[1]: windowname='ROXTerm', tabname[1,2,3]==default
    window[2]: windowname='foo', tabname[1]=='foo', tabname[2,3]==default
    window[3]: windowname='bar', tabname[1]=='bar', tabname[2,3]==default
    window[4]: windowname='baz', tabname[1]=='baz', tabname[2,3]==default

    I want only 1 window! So I tried following the header above with the following bash code:

    PROFILE_NAME='profile_with_3_init_tabs'
    show_profile
    roxterm --profile ${PROFILE_NAME} --title ${WINDOW_NAME}
    roxterm --profile ${PROFILE_NAME} --tab -n 'foo'
    roxterm --profile ${PROFILE_NAME} --tab -n 'bar'
    roxterm --profile ${PROFILE_NAME} --tab -n 'baz'
    

    Even more annoyingly, that creates 4 windows IN SUCCESSION, each with 3 tabs.

    1. See window[1]: windowname='ROXTerm', tabname[1,2,3]==default. Kill that, ...
    2. See window[2]: windowname='foo', tabname[1]=='foo', tabname[2,3]==default. Kill that ...
    3. See window[3]: windowname='bar', tabname[1]=='bar', tabname[2,3]==default. Kill that ...
    4. See window[4]: windowname='baz', tabname[1]=='baz', tabname[2,3]==default. Kill that, no more windows.

    So I tried following the header above with the following bash code:

    PROFILE_NAME='profile_with_3_init_tabs'
    show_profile
    roxterm --profile ${PROFILE_NAME} --title ${WINDOW_NAME} --fork
    roxterm --profile ${PROFILE_NAME} --title ${WINDOW_NAME} --tab -n 'foo'
    roxterm --profile ${PROFILE_NAME} --title ${WINDOW_NAME} --tab -n 'bar'
    roxterm --profile ${PROFILE_NAME} --title ${WINDOW_NAME} --tab -n 'baz'
    

    The result, at end of script, is 2 separate windows (simultaneously showing), each with 3 tabs:

    window[1]: windowname='ROXTerm', tabname[1,2,3]==default
    window[2]: windowname='ROXTerm'', tabname[1]=='foo', tabname[2,3]==default

    Killing window[1] only makes it go away. Killing window[2] causes window[3] to display:

    window[3]: windowname='ROXTerm', tabname[1]=='bar', tabname[2,3]==default

    Kill that, and I see

    window[4]: windowname='ROXTerm', tabname[1]=='baz', tabname[2,3]==default

    (Kill that, no more windows.) So obviously I'm doing something wrongly. What do I need to do to automate the creation of a single

    window[1]: windowname='ROXTerm', tabname[1]=='foo', tabname[2]=='bar', tabname[3]=='baz'

    ? Alternatively, if this is not currently possible, please lemme know, and I'll make a FR.

     

    Last edit: Tom Roche 2015-08-05
  • Tony Houghton

    Tony Houghton - 2015-08-06

    The following works for me. Note that the first call opens a window and tab even if you use --fork, so you need to add your first tab name to that command. Don't use init_tabs=3. Let me know if it still doesn't work, it means I need to solve a race condition.

    1
    2
    3
    4
    5
    6
    7
    8
    #!/bin/sh
    
    WINDOW_NAME="ROXTerm"
    PROFILE_NAME=Default
    
    roxterm --profile=$PROFILE_NAME --title=$WINDOW_NAME -n foo --fork 
    roxterm --profile=$PROFILE_NAME --title=$WINDOW_NAME -n bar --tab
    roxterm --profile=$PROFILE_NAME --title=$WINDOW_NAME -n baz --tab
    
     
  • Tom Roche

    Tom Roche - 2015-08-06

    summary: Thanks for your provided scriptlet, but it fails for me: configuration and failure mode details below.

    details:

    I'm currently running

    $ date
    Thu Aug  6 12:34:34 EDT 2015
    $ cat /etc/debian_version
    8.1
    $ uname -rv
    3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1+deb8u2 (2015-07-17)
    $ gcc --version | head -n 1
    gcc (Debian 4.9.2-10) 4.9.2
    $ roxterm --version
    # you really should support `--version`
    ** (roxterm:10272): WARNING **: Error parsing command line options: Unknown option --version
    Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.
    

    but I can see from the GUI that I'm running roxterm version=2.9.5. When I close that, I have no open ROXTerm windows, so I open a gnome-terminal and do

    $ date ; pgrep -l rox
    Thu Aug  6 12:35:08 EDT 2015
    $ date ; pgrep -l roxterm | wc -l
    Thu Aug  6 12:35:13 EDT 2015
    0
    

    I then cut'n'paste your scriptlet

    WINDOW_NAME="ROXTerm"
    PROFILE_NAME=Default
    roxterm --profile=$PROFILE_NAME --title=$WINDOW_NAME -n foo --fork 
    roxterm --profile=$PROFILE_NAME --title=$WINDOW_NAME -n bar --tab
    roxterm --profile=$PROFILE_NAME --title=$WINDOW_NAME -n baz --tab
    

    into the gnome-terminal and get 2 windows. The first window to appear (I'll call it window[1]) has the correct window name=ROXTerm, but only a single tab with tabname=foo. window[1] is immediately covered by window[2], which also has the correct window name, but also only a single tab (with tabname=bar). When I kill window[2] (with S-C-q followed by clicking the confirmation), I immediately get window[3], which again has the correct window name, but again only a single tab (tabname=baz). After that, I see and kill window[1], after which there are no more ROXTerms.

    I then created and ran /tmp/ROXTerm-setup.sh as follows:

    $ date ; ls -al /tmp/ROXTerm-setup.sh
    Thu Aug  6 12:47:56 EDT 2015
    -rwxr-xr-x 1 me me 524 Aug  6 12:47 /tmp/ROXTerm-setup.sh
    
    $ date ; cat /tmp/ROXTerm-setup.sh
    Thu Aug  6 12:48:00 EDT 2015
    #!/usr/bin/env bash
    ### ROXTerm-setup.sh : setup a ROXTerm terminal
    ### see discussion @ https://sourceforge.net/p/roxterm/discussion/422639/thread/44342a81/
    ### esp reply @ https://sourceforge.net/p/roxterm/discussion/422639/thread/44342a81/#ed8a
    
    WINDOW_NAME='ROXTerm'
    PROFILE_NAME='Default'
    roxterm --profile="${PROFILE_NAME}" --title="${WINDOW_NAME}" -n 'foo' --fork 
    roxterm --profile="${PROFILE_NAME}" --title="${WINDOW_NAME}" -n 'bar' --tab
    roxterm --profile="${PROFILE_NAME}" --title="${WINDOW_NAME}" -n 'baz' --tab
    
    $ date ; /tmp/ROXTerm-setup.sh
    Thu Aug  6 12:48:07 EDT 2015
    

    I got identical results to previous:

    1. window[1] appears: windowname=ROXTerm, tabname[1]==foo (no other tabs unless stated)
    2. window[2] immediately covers window[1], has same windowname, but tabname[1]==bar
    3. Killing window[2] causes window[3] to display: same windowname, tabname[1]==baz
    4. Killing window[3] reveals window[1].
    5. After killing window[1], nothing.
     
  • Tony Houghton

    Tony Houghton - 2015-08-07

    I've made a change which should make --fork wait until the dbus service is really ready. Can you test git? It includes the debian packaging so all you should have to do to build it is:

    debuild -b -uc -us

    You'll need to install build dependencies too, but rather than using apt-get build-dep I recommend running debuild first and working out what you need from the error message, because the deps have changed a lot since 2.9.5. The core packages are now roxterm-data and roxterm, you won't need to install roxterm-gtk3. There is no longer a GTK2 version, only a dummy transitional package is left.

    All those changes are basically the reason 3.0.2 is taking a long time to make it into Debian officially.

     
  • Tom Roche

    Tom Roche - 2015-08-08
    Tony Houghton
    >> I've made a change which should make --fork wait until the dbus service
    >> is really ready. Can you test git? It includes the debian packaging so
    >> all you should have to do to build it is: debuild -b -uc -us
    

    TH: I've gotta get some other stuff done at the moment, but should have some spare time soon.

    JP Vossen
    > Maybe see also https://sourceforge.net/p/roxterm/discussion/422639/thread/aef31b68/
    

    JPV: That usecase seems quite unlike mine. I'm trying to name multiple tabs in a single window; your link is about "[creating a] RoxTerm profile on the fly]." But IIUC one cannot name ROXTerm tabs in a profile--or am I missing something?

    TH: that being said, ISTM that saving tab names in a profile would be a very natural way to serialize a window configuration. Is this something you've thought about? Would it be worth my while to make an FR?

     
  • Tony Houghton

    Tony Houghton - 2015-08-08

    There's an obvious demand for a better way to automate opening of multiple tabs so I'm doing something about it. ROXTerm includes code for session management which can easily be adapted to support user sessions as well as being tied into desktop sessions. So you'll be able to create the windows and tabs you want, save the session with a name, then in future give roxterm a CLI option with that name to restore the same windows and tabs (but without the content of course).

     

Log in to post a comment.