Assigning Applications to Particular Workspaces in i3

Reading Time: 2 minutes

I’ve been using i3 on Manjaro recently and I noticed in the default configuration that there were examples where I could assign applications so that whenever I open then, they’ll always open on the same workspace:

$ grep -A5 "Open applications" ~/.i3/config                                                                                                                                                                       
# Open applications on specific workspaces
# assign [class="Thunderbird"] $ws1
# assign [class="Pale moon"] $ws2
# assign [class="Pcmanfm"] $ws3
# assign [class="Skype"] $ws5

I started to play with this and found that all of my terminal applications that I launched with MOD+d (dmenu)  would not be assigned appropriately. Applications such as neomutt, irssi etc.
NOTE: You can get a list of applications that dmenu launces via terminal at ~/.config/dmenu-recent/terminal

I found the documenattion for i3 assignments here: i3 Assignments

I also found the command criteria here: i3 Command Criteria

After reading that I had a hunch that the class command criteria didn’t match the name of the application because dmenu was launching the application via the terminal.

I eventually stumbled upon this genius answer on the unix stack exchange site.

I learned about the xprop command wich will give you the values of variables such as WM_CLASS etc. For example:

$ xprop                                                                                                                                                                                                    
WM_STATE(WM_STATE):
		window state: Normal
		icon window: 0x0
_NET_WM_DESKTOP(CARDINAL) = 2
_NET_WM_PID(CARDINAL) = 1114
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, _NET_WM_PING
WM_LOCALE_NAME(STRING) = "en_US.UTF-8"
WM_CLASS(STRING) = "urxvt", "URxvt"
WM_HINTS(WM_HINTS):
		Client accepts input or input focus: True
		Initial state is Normal State.
		window id # of group leader: 0x18000fa
WM_NORMAL_HINTS(WM_SIZE_HINTS):
		program specified minimum size: 13 by 22
		program specified resize increment: 9 by 18
		program specified base size: 4 by 4
		window gravity: NorthWest
WM_CLIENT_MACHINE(STRING) = "hostname"
WM_COMMAND(STRING) = { "urxvt", "-cd", "/home/loweryaustin", "-e", "neomutt" }
_NET_WM_ICON_NAME(UTF8_STRING) = "neomutt"
WM_ICON_NAME(STRING) = "neomutt"
_NET_WM_NAME(UTF8_STRING) = "neomutt"
WM_NAME(STRING) = "neomutt"

You’ll notice that the class is set to urxvt for neomutt! So attempting to assign neomutt to a workspace using the class command criteria will never work.

Looking back at the command criteria documentation referneced above, we can see that the title command criteria matches the WM_NAME variable.

My config now looks like this, and it works great:

$ grep -A5 "Open applications" ~/.i3/config                                                                                                                                                                
# Open applications on specific workspaces
assign [class="qutebrowser"] $ws2
assign [title="neomutt"] $ws3
assign [title="calcurse"] $ws4
assign [title="irssi"] $ws5

Leave a comment if you have any feedback or questions.

Leave a Reply

Your email address will not be published. Required fields are marked *