How can I start applications on specific workspaces in i3 when it starts?
Why is this not working in my config file? :
workspace 1; exec firefox; workspace 2; exec chromium; workspace 1 According to the Arch Wiki i3 page, to autostart an application on a specific workspace, you use i3-msg:
exec --no-startup-id i3-msg 'workspace 1:Web; exec /usr/bin/firefox' exec --no-startup-id i3-msg 'workspace 1; exec firefox; workspace 2; exec urxvt; workspace 1' works. But, I find it a little odd to use exec on i3-msg which is a command meant to execute i3 commands. Why can't I directly write workspace 1; exec firefox; workspace 2; exec urxvt; workspace 1 in my config file? google-chrome-stable always opens on the last workspace in my setup. For example, with this configuration, Chrome opens on workspace 4 next to htop. && sleep 3 and I'd bet Chrome opens in workspace 3. May need to go as high as 5 depending on # of extensions. # This is what I use in ie config # custom variables for workspaces set $ws1 "1< txt >" set $ws2 "2> fm " set $ws3 "3< Web >" set $ws4 4 set $ws5 5 set $ws6 6 set $ws7 7 set $ws8 8 set $ws9 9 ##==================================================## # *** Workspace specific settings *** # ##=================================================## # Assign Workspaces: assign [class="Firefox"] $ws3 assign [class="Chromium"] $ws3 assign [class="Google-chrome-beta"] $ws3 assign [class="^Geany"] $ws1 NOTE: to apply config, you can use:
i3-msg reload
class argument. Is there any way to know exactly to which class is an application associated? xprop | grep CLASS in terminal, your mouse pointer changes into a crosshair, you click on the program you want to get the class of and use the second variable that comes up in your terminal. Example result for Chrome: WM_CLASS(STRING) = "google-chrome", "Google-chrome" xprop command the windows are not assigned to the desired workspace. for_window [class="Spotify"] move to workspace $ws10 where $ws10 is your workspace variable. It's an autostart on workspace launch only, not an autostart when i3 starts but I thought it could be useful.
For example, to launch my web browser in the named second workspace "web" this is what I did in my config :
bindsym $mod+2 workspace 2:web; layout tabbed; exec [ $(ps h -C vimb | wc -l) = 0 ] && /usr/bin/vimb -s
When I hit key 2, my web browser starts but when it's already opened it didn't relaunch it, it just switch to the web workspace.
Note: the layout part can be annoying sometime, it's not a requirement.
For more details see my conf
pidgin to 3-rd workspace on its every launch, I have in the config assign [class="Pidgin"] $tag3. I just got it working with this at the end of my ~/.config/i3/config file:
for_window [class="Firefox"] move container to workspace 2 exec --no-startup-id firefox set $ws1 "Firefox" and then insert following line for_window [class="Firefox"] move to workspace $ws1 Just use assign [class="<use your program name here e.g. - Firefox>"] $workspace<eg. 5>. It is working for me.
Old thread, but I found a method without outright assigning the application using assign and via i3-msg and either moving to the workspace, or moving the window to the workspace, which is prone to race conditions and not as elegant.
Regardless, what I ended up doing was assigning custom classes to each workspace.
assign [class="app-ws1"] $ws1 assign [class="app-ws2"] $ws2 ... And then starting the application, telling it to use that class. (if it supports that)
exec --no-startup-id kitty --class app-ws1 exec --no-startup-id firefox --class app-ws2 I hope this was helpful!!
edit: In the case of Firefox, (and kitty if you want) this method is a bit... lacking. Since they re-use the same window instance multiple times. Meaning the same class is used, and we're back at the initial problem. @jasonwryan's answer would likely be a better catch-all. Still, I find this an interesting alternative in some cases where it could be applicable.