The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
1

How to open a program's child processes in tabbed view?

asked Jan 8 '15

luke gravatar image

A lot of the time I work from a terminal and when I need to use a graphical application to edit a file in the current directory it's so much faster to type prog-name [filename] instead of launching it from dmenu then attempting to navigate to the file.

My problem is when launching graphical applications, logically, half my screen gets wasted, covered with stdout (of which I rarely need) causing me to waste time rearranging windows. It would be great if once launched, a graphical application used the full space of the terminal and sticks the terminal in a new tab. It can be done manualy, $mod + v before launching and $mod + w after, creates a tabbed container displaying the launched program and hiding the terminal in the other tab, it's just irritating and time-wasting to repeat this every single time.

So, Is there anyway this could be automated?

Can I set i3 to automatically display windows of xfce4-terminal's child processes this way? If not, could I even just use a script (e.g.script-name prog-name [filename]) to achieve this?

3 answers

Sort by » oldest newest most voted
1

answered Jan 9 '15

cee gravatar image

You could define an alias tab='i3-msg layout tabbed && ' that can be prepended to your command to start any GUI program.
Of course you could also wrap it in a shell script for some more advanced features.

0

answered Jan 13 '15

Ternary gravatar image

This isn't exactly what you're asking for, but it sounds like you might want these 'gui' programs to always open in floating mode by default.

Here are two example lines from my i3/config that do this for gimp (and all of its associated windows) and audacious respectively:

for_window [class="gimp"] floating enable
for_window [title="Audacious"] floating enable
0

answered Jan 10 '15

luke gravatar image

updated Jan 10 '15

I have been able to achieve this using cee's suggestion of aliases and i3-msg. However, cee's suggestion alone did not work when additional windows existed in the terminals container. To fix this I needed to run additional commands to ensure a new container was created and then later removed.

My final solution was to add this to my shell's rc file:

i3-gui(){
    # Create tabbed container.
    i3-msg split v > /dev/null
    i3-msg layout tabbed > /dev/null

    # Run program.
    $@

    # Remove container.
    i3-msg move up > /dev/null
    i3-msg move down > /dev/null
}
# Aliases for programs with a gui.
alias feh="i3-gui feh"
alias gimp="i3-gui gimp"
alias mpv="i3-gui mpv"
alias libreoffice="i3-gui libreoffice"

This is still not the best answer to the question as it does not automatically do this for child processes of the terminal like asked. However seems to solve my problem the best as for some programs this behavour may not be desired.

Question Tools

Stats

Asked: Jan 8 '15

Seen: 403 times

Last updated: Jan 13