In i3wm how can I open programs on another workspace at startup?

7.2k views Asked by At

I've tried multiple ways in my config file to get chromium to open on $ws2 but it just keeps opening on $ws1 on startup.

2

There are 2 answers

2
AudioBubble On BEST ANSWER

First you have to find the WM_CLASS(STRING) from xprop. Open xprop and click on the target window you'll see the information about that window. Find WM_CLASS(STRING) second string(for i3wm) then goto the config file of i3 wm .config/i3/config and define the rule like this for_window [class="Chromium"] move to workspace $ws2 for_window [class="TelegramDesktop"] move to workspace $ws3 Here replace the class="String" with the string we found before with xprop. enter image description here

enter image description here

Alternatively, follow the instructions in section 4.17 of the i3 User’s Guide and insert into your config file an assign declaration e.g. assign [class="Chromium"] $ws2. This will open the program directly on the specified workspace. For less well behaved programs like Spotify the for_window ... move to workspace ... method is required to move the program after it has opened, however.

0
Sharfus On

To open a PROGRAM (chromium in your case) on a particular workspace during startup and return to your first workspace:

1: Add the following to your ~/.config/i3/config file.

exec --no-startup-id i3-msg 'workspace $ws2; exec PROGRAM; workspace $ws1'

1a: Substitute the name of the workspace you want to use for '$ws2' in the example.

1b: Substitute the name of the program to run(execute) with any options for PROGRAM. No quotes are needed for this section

1c: Substitute the name of the workspace you want to return to for '$ws1' in the example, or leave off "; workspace $ws1" to land in $ws2.

1d: Ensure you have the single quote mark where I included them in the example

2: Save the edit (I leave the editor open in case I have to change the file back after restart in place)

3: To test:

3a: Have i3 reread the config file (mod4+shift+c on my system)

3b: Restart i3 in place (mod4+shift+r on my system)

Note: I use $ws1 $ws2 etc in my config because once those are configured it made it easier for me to change titles and awesome icons in just one place vs many places. Method shamelessly stolen from i3 and others as is all of my linux knowledge. :-)