I3wm: Open terminal on startup on a specific workspace?

I want to add a line to my i3 config file that opens up the terminal on one specific workspace. The issue is I already predefined some workspaces, and assigned classes to them.

Here is the quick PASTEBIN of the relevant part of my config.

I want from i3 to run a terminal on my $workspace6 upon Login.
What I tried (just for the sake of testing):

exec --no-startup-id i3-msg 'workspace 7:mongod; exec i3-sensible-terminal'

What I got back:

  • A workspace “7:web” was created upon Login
  • A terminal was executed, but in $workspace1 because of the assign

Any ideas how to solve this? Thanks.

You could try to work around your problem with instances or titles on assignments. The first assignment seems to overrule the second one.

assign [class="Gnome-terminal" instance="<instance>" title="<title>"] $workspace7
assign [class="Gnome-terminal" ] $workspace1
2 Likes

Will try that out, thanks.
But what should I name the <instance> and <title> by?
Just random names? I’m guessing they have a use, I just don’t see where.

You can check the window instance with xprop. The first value of WM_CLASS(STRING) is the instance and the second is the class. Title is what ever is written on the window title. You don’t have to use both instance and title, I just put both of those options in the same example.

I am trying to think a clean way of setting instance or window title on gnome-terminal but haven’t come up with one. gnome-terminal should have the --name= and --class= parameters but they didn’t seem to work for me.

1 Like

Alright I will try to work it out. Thanks for the replies.
P.S. HERE is the only connected thing that I found, but I can’t make much sense out of it. Maybe it will help you.

I actually didn’t know it was that easy with urxvt. This should work:

exec --no-startup-id i3-msg 'workspace 7:mongod; exec urxvt -name mongod'

xprop should show this: WM_CLASS(STRING) = “mongod”, “URxvt”

assign [class="URxvt" instance="mongod"] $workspace7
assign [class="URxvt" ] $workspace1

You also could make urxvt open the program by adding -e parameter followed by command

exec --no-startup-id i3-msg 'workspace 7:mongod; exec urxvt -name mongod -e mongod'
1 Like

Alright, nice! Thanks for all the help! :smile:
The L1T community is really amazing.

I open a term on my 1st workspace upon login. I just used the workspace var in the i3-msg command.

.config/i3/config:

...
set $ws1  "1: "
...
set $monr "HDMI-1"
...
workspace $ws1  output $monr
...
exec --no-startup-id i3-msg 'workspace $ws1; exec termite'
...
1 Like