Binding google-chrome tabs to certain workspaces in i3-wm

I am aware that it is possible in i3-wm to bind certain apps to certain workspaces and certain workspaces to certain displays(I have a dual monitor setup). Is it also possible to bind specific google-chrome tabs to certain worspaces/displays?
For those of you wanting to know how I do the app-workspace, or workspace-display binding, here’s a snippet of my i3config:

# binding workspaces to displays(run xrandr --query to get display names)
workspace $ws1 output "eDP-1" workspace_layout tabbed
workspace $ws2 output "HDMI-1" workspace_layout tabbed
workspace $ws3 output "HDMI-1" workspace_layout tabbed
workspace $ws4 output "eDP-1" workspace_layout tabbed
workspace $ws5 output "HDMI-1" workspace_layout tabbed

# Bind App to workspaces
# Check class by using xprop command
assign [class="Google-chrome"] $ws1
assign [class="Nemo"] $ws2
assign [class="eDEX-UI"] $ws2
assign [class="Vlc"] $ws5
assign [class="crx_eppojlglocelodeimnohnlnionkobfln"] $ws5
Asked By: ShuaibKunji

||

It is possible to assign an application to a specific workspace using its window class and instance. For example, for chromium it will be:

WM_CLASS(STRING) = "chromium-browser", "Chromium-browser"

But problem here is that each Chromium tab has the same window class. You could only change it for the whole running instance:

$ chromium-browser --class='new-class'

So you can’t assign separate tabs to different workspaces. The only workaround for that is to use Chromium in app mode by launching each tab manually from command line:

$ chromium-browser --app='https://www.linux.com/'

That way each tab will be created as a different instance:

WM_CLASS(STRING) = "www.linux.com", "Chromium-browser"
Answered By: anlar

What worked for me was using the class and instance(string before the comma in WM-CLASS when using xprop) when binding the tab(instance) to a workspace.

For netflix for example, I first went to netflix and clicked on the 3 dots next to the address bar in google-chrome and then More tools>Create shortcut. This creates a shorcut of the instance of google-chrome for the URL on your desktop.

You can check the properties of the dektop shortcut using any file manager and copy the contents of the command section and paste it in your key-binding line after exec in your i3config like so:

bindsym $mod+n exec /opt/google/chrome/google-chrome --profile-directory=Default --app-id=eppojlglocelodeimnohnlnionkobfln

Use the binding to summon the instance, run xprop in the terminal and click on the instance window to pull the details. Mine returned:

WM_CLASS(STRING) = "crx_eppojlglocelodeimnohnlnionkobfln", "Google-chrome"

Then simply use the string before the comma as the instance and the string following the comma as the class, like so:

assign [class="Google-chrome" instance = "crx_eppojlglocelodeimnohnlnionkobfln" title = "Netflix"] $ws5

Hope this helps who was just as stuck as I was. 🙂

Answered By: ShuaibKunji

Binding a specific Chrome window can be done by its title property:

  1. In your i3 config, launch Chrome and give it an "app" argument.

exec google-chrome --app="https://app.excalidraw.com/"

  1. Use xprop in your terminal to get the WM_NAME(UTF8_STRING) value. I believe that this is the same value that shows as the title on the top of the Chrome window when you launch the app. For excalidraw, the value was Excalidraw Plus — Workspace dashboard.
  2. In your i3 config, use that value to assign the window to a workspace like this:

for_window [title="Excalidraw Plus — Workspace dashboard"] move to workspace $ws3

Answered By: Nathan

in your i3 config:

# google voice
exec google-chrome-stable --app="https://voice.google.com"
assign [instance="voice.google.com"] $ws2

where your instance is the first string that returns in ‘CLASS’ when you use xprop:

...
WM_CLASS(STRING) = "voice.google.com", "Google-crome"
..
Answered By: diyer0001
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.