You are not logged in.

#1 2016-03-25 09:40:09

searene
Member
Registered: 2016-03-25
Posts: 8

[SOLVED]i3wm: autostart apps on respective workspaces when i3 starts

I want to start some applications on respective workspaces when i3 starts. After reading the i3 documentation and searching online, I found a possible solution, which is to put the following lines in ~/.config/i3/config

exec --no-startup-id i3-msg 'workspace 1; exec /usr/bin/mate-terminal; workspace 2; exec /usr/bin/google-chrome-stable; workspace 3; exec /usr/bin/gvim; workspace 4; exec /usr/bin/goldendict; workspace 5; exec /usr/bin/anki; workspace 6; exec /usr/bin/caja; workspace 7; exec /usr/bin/virtualbox'

It doesn't work properly. Some apps start on the wrong workspace. As you can see, I start only one app per workspace, but some apps start on the same workspace, which is usually the seventh workspace, the last one.

Did I do something wrong, or is it a bug of i3wm?

Last edited by searene (2016-03-26 12:47:37)

Offline

#2 2016-03-25 11:20:50

Awebb
Member
Registered: 2010-05-06
Posts: 6,688

Re: [SOLVED]i3wm: autostart apps on respective workspaces when i3 starts

Your solution is hackish. It does not tell the program where to spawn, it rather forces the desktop to switch workspaces and then start programs. The problem is, that your apprach will switch the workspace as soon as the command is running. The problem with X applications is (and it's only a problem in this instance), the application itself is responsible for drawing the window, so when the application has been started, it might take a second to create the window. Your script forces the manager to switch workspaces before the application is done drawing the window. It pops up on the current workspace.

To circumvent this, use xprop to learn more about the windows you want to place and assign them a permanent "on startup" workspace:

# application rules
        # chromium
                assign [class="Chromium"] → 2
        # pulsaudio
                assign [class="Pavucontrol"] → 9
        # Skype
                assign [class="Skype"] → 7
                for_window [class="Skype"] tabbed
        # XBMC, Kodi
                assign [class="Kodi"] → 10
                for_window [class="Kodi"] fullscreen
        # KeePass2
                assign [class="KeePass2"] → 8
        # Steam
                assign [class="Steam"] → 6
        # sakura
                for_window [class="sakura"] border 1pixel

This way, every time you start Chromium, it goes to [2].

If you don't want this, you need to write a wrapper, that moves an already launched window to the right workspace. If all you want is a certain layout after logging in, look up i3-save-tree. https://i3wm.org/docs/layout-saving.html

Last edited by Awebb (2016-03-25 11:21:36)

Offline

#3 2016-03-26 01:39:53

searene
Member
Registered: 2016-03-25
Posts: 8

Re: [SOLVED]i3wm: autostart apps on respective workspaces when i3 starts

Thanks for such a detailed answer, assigning workspaces to respective classes or windows solves the problem.

Offline

Board footer

Powered by FluxBB