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
up vote 52 down vote accepted
+50

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'
  • 4
    Yes, a line like 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? – Gradient Oct 24 '13 at 5:05
  • 1
    This just opens everything in Workspace 1 for me. – cmc Oct 30 '14 at 16:15
  • 3
    Works for most apps. However 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. – danijar Jun 23 '15 at 20:05
  • 1
    Note that i3 now provides layout saving/restoring features that make it unnecessary to call i3-msg in most cases. – Wieland Apr 16 '16 at 15:32
  • @Wieland you should just edit that in to the answer... – jasonwryan Apr 16 '16 at 19:42

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

  • You can do it much easily by assigning workspace. For example to move pidgin to 3-rd workspace on its every launch, I have in the config assign [class="Pidgin"] $tag3. – Hi-Angel Oct 23 '16 at 2:34
  • Assigning to a workspace is different. @tyjak's solution will cause an application to launch when you open a particular workspace. Assigning an application to a workspace will cause that application to be moved to a workspace whenever you open it. – Mike Nov 19 '16 at 8:29
# 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

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
  • According to Arch Linux i3 Example for Firefox: First set your variable set $ws1 "Firefox" and then insert following line for_window [class="Firefox"] move to workspace $ws1 – Markus Weber Nov 25 at 0:05

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.