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
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 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'
Method 2
# 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
Method 3
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
Method 4
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
Method 5
Just use assign [class="<use your program name here e.g. - Firefox>"] $workspace<eg. 5>.
It is working for me.
Method 6
My config:
##################################
Worskpace Settings
##################################
assign [class=”Code”] $ws4
assign [class=”jetbrains-studio”] $ws4
assign [class=”winword.exe”] $ws5
assign [class=”excel.exe”] $ws5
assign [class=”powerpnt.exe”] $ws5
for_window [class=”Firefox”] move to workspace $ws3
for_window [class=”Spotify”] move to workspace $ws6
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0