How to define different layouts for different workspaces?

I’m trying figure out how to define that “workspace 7” opens up “tabbed” by default while at least workspaces 1-6 are autotiling.

I am using an nwg-piotr’s autotiling script which is set to work on “workspaces 1-6”. So the work around i came up with is setting the default layout as “tabbed” since 1-6 should be autotiling, and it works i thought it was working, but now it’s not. Somehow ‘tabbed’ layout take priorty over the autotiling script for all workspaces.

Any tips on how to proceed are greatly appreciated.

Thank you

1 Like

Try to add to your i3wm config something like this.

for_window [workspace="7"] floating enable

I do not know if that actually works or not. The "7" should be name of the workspace so maybe it should be "workspace 7" instead.

1 Like

Hey, thank you for the reply.
K I tried:
for_window [workspace=“7”] tabbed enable

No luck yet,
I think “tabbed” is only recognized as an input when it is “workspace_layouts” precedes. However, “workplace_layouts” will only set a default for “all” work spaces

Sorry, I do not know why I read floating instead of tabbed. :man_facepalming:
Try this

for_window [workspace="7"] layout tabbed

It is the same logic as you can find in the i3wm documentation

bindsym $mod+s layout stacking
bindsym $mod+l layout toggle split
bindsym $mod+w layout tabbed

Instead of bindsym to a keyboard key press you bind it to a certain workspace condition (when a new window appears on that workspace).

It has a sideeffect that you will not be able to use different layout on that workspace because any new window will force the layout to the tabbed version.

2 Likes

Thank you again for continuing to go through this with me

I am still trying different methods of inputting the logic you are getting at

so far, what i have been able to do is have have ‘workspace 7’ open on my external/secondary monitor or DP-1

and with a script called “i3-autolayout” i have this:

“exec_always --no-startup-id i3-autolayout tabmode --workspace-num 7”

So workspace 7 will always start tabbed, but if i kill the windows and switch workspaces on that monitor, it will not come back tabbed anymore unless i “restart” i3 or manually toggle tabbed more for that workspace

Day 2, I’ll keep trying different ways to input the bind command for tabbed layout thank you

This just looks like some kind of script that is run on every start of i3.
You can open it in a text editor and look what i3-autolayout does assuming it is some kind of script.

If that script is terminated every time you close all windows then you can easily create a systemd service that will autorestart when i3-autolayout terminates.

if i run the command in terminal without workspace 7 opened I get this output

I think i need to figure out a systemd service which will trigger that command when workspace 7 is opened

if workspace exit… it works… but number will not be the same in cases… so you need to know or script something around it… like this creating a new empty workspace and have a variable for the number it will be… to use for the command… not sure if an empty workspace is what you want…

#!/bin/bash

MAX_DESKTOPS=20

WORKSPACES=$(seq -s '\n' 1 1 ${MAX_DESKTOPS})

EMPTY_WORKSPACE=$( (i3-msg -t get_workspaces | tr ',' '\n' | grep num | awk -F:  '{print int($2)}' ; \
            echo -e ${WORKSPACES} ) | sort -n | uniq -u | head -n 1)

i3-msg workspace ${EMPTY_WORKSPACE}
i3-autolayout tabmode --workspace-num ${EMPTY_WORKSPACE}
1 Like

Thank you for the reply, I feel like I’m getting close. I just want workspace 7 to be tabbed. i have created the script, and it “works” if i execute it in terminal, but how do i tie it to work automatically when workspace 7 is opened? Do i need a systemd service file? i have been unable to figure out how to bind a command to a workspace in the i3 config file .

Thank you again for your time

so how do you create workspace 7 in the first place?
I have workkspaces set to get started by default but using names not numbers…
This assigns gimp to ws7 and ws7 is named gimp so when i start gimp it opens ws7 …

set $ws7 "7:gimp"
workspace $ws7 output HDMI-0
assign [class="Gimp"] $ws7

the problem is indeed that $ws7 is getting created when gimp is started … so you need to simple use the script instead of the app but asssign will not work … for scrip so it could help to use a custom desktop file for an application you do want to start on $ws7 …it is handling wiondows mainly :wink:

a desktop file for an exiting app would get identified with the same class and you could change exec in that to use the the command after the app Exec=gimp && i3-autolayout tabmode --workspace-num 7

seems a bit complicated…

looks like it will need to first create empty workspace / set this tabbed / open app assigned to it…
and no clue how to create explicitly workspace 7 empty… so wrong path i think…

1 Like

Is my previous suggestion with for_window [workspace="7"] layout tabbed not working as you want?

You can also try to add command to the action when you switch to the workspace 7 like so

bindsym $mod+7 workspace $ws7; layout tabbed

or with some exec script

bindsym $mod+7 workspace $ws7; exec --no-startup-id something-something-make-it-tabbed.sh

And this something-something-make-it-tabbed.sh script would contain a logic.

#!/bin/bash

if "no window on workspace 7"; then
   i3-msg layout tabbed
else
   "do nothing"
fi
3 Likes

This worked and gave me an idea how to assign tabbed for the specific app which ended up being:

for_window [class=smplayer] layout tabbed

thank you so much both @vlkon and @joekamprad for your guidance, this will take my productivity level even further… beyond :sunglasses:

and i used the

but changed the gimp to smplayer

2 Likes

Only needs the pencil changed to a movie :popcorn: awesome font icon…

1 Like

Thank you, yes, I settled on  this icon

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.