Sway: spotify escapes workspace assignment

Created on 28 Feb 2019  路  15Comments  路  Source: swaywm/sway

A couple of apps assigned to workspaces here:
assign [class="Mixxx"] 6
assign [class="Carla"] 7
assign [class="Audacity"] 8
assign [class="Spotify"] 7
assign [class="Firefox"] 9
assign [class="Cadence"] 10

among which Spotify doesn't work.
I'm not 100% sure, but AKAIR it has been working recently,

Most helpful comment

@japhir, it looks like you are using:

for_window [class="Spotify"] move to workspace $ws10

You can try one of the following (both should work):

for_window [class="Spotify"] move window to workspace $ws10
# -- or --
for_window [class="Spotify"] move container to workspace $ws10

Currently sway requires an explicit window/ container, whereas i3 does not. I'll submit a PR within the next couple hours to add the missing syntax options that i3 allows for (https://github.com/i3/i3/blob/a574346964ce17d35df2ef9072ba16e26209ac84/parser-specs/commands.spec#L316-L324)

@AndreasBackx, I'm going to take a guess that you omitted the window/container as well. If you are using the 1.0 release, you can switch to one of the syntax options above. If you are on git master, the PR should be up shortly

Update: The PR can be found at https://github.com/swaywm/sway/pull/4069

All 15 comments

Can you share the output of swaymsg -t get_tree when Spotify is running?

Also a debug log.

swaymsg -t get_tree: sway-tree-4-spotify.log
NB: Updated to match the session of the console debug log reported further down.

sway -d >sway.log 2>&1

console debug from start to exit:
sway.log
NB: The tree logged above belongs to this session.

I've trim down the sway/config for logging.
Then put it back together with a few changes, e.g. the way and order to start jackdbus related stuff.
Now spotify is properly assigned.

Will come back here if something more consistent is to be reported.
Confused :((

Even more confused:
Before I got your reply, I've rebuilded sway with -ggdb CFLAGS, which seems the reason why Spotify assignment got to work all of a sudden!!!
I understood that as I reverted sway build to normal, then restarted.

This is an issue with Spotify itself. It is setting WM_CLASS after mapping so assign commands are not going to work with it (and it is also a ICCCM violation). According to a Spotify developer in 2016, it is a limitation of the way they are using the Chromium Embedded Framework (CEF).

i3 recommends using the following instead (which is working for me in Sway):

for_window [class="Spotify"] move container|window to workspace $workspace

sway version 1.0-rc1-138-g43035951 (Mar 2 2019, branch 'HEAD')
-
Additionally, log reports:
2019-03-01 15:28:37 - [sway-9999/sway/commands.c:253] Handling command 'exec spotify'
2019-03-01 15:28:37 - [sway-9999/sway/commands.c:145] find_handler(exec)
2019-03-01 15:28:37 - [sway-9999/sway/commands/exec_always.c:46] Executing spotify
Failed to connect to user bus: No such file or directory
2019-03-01 15:28:37 - [sway-9999/sway/commands/exec_always.c:87] Child process created with pid 13356
2019-03-01 15:28:37 - [sway-9999/sway/tree/root.c:253] Recording workspace for process 13356

Thks

The workaround hasn't worked for me in a while now. Any ideas?
First 1300 lines of sway.log (seems to continue logging even though I tried not to ;-))

Same here, I cannot get this assignment to work like it used to work in i3.

@japhir, it looks like you are using:

for_window [class="Spotify"] move to workspace $ws10

You can try one of the following (both should work):

for_window [class="Spotify"] move window to workspace $ws10
# -- or --
for_window [class="Spotify"] move container to workspace $ws10

Currently sway requires an explicit window/ container, whereas i3 does not. I'll submit a PR within the next couple hours to add the missing syntax options that i3 allows for (https://github.com/i3/i3/blob/a574346964ce17d35df2ef9072ba16e26209ac84/parser-specs/commands.spec#L316-L324)

@AndreasBackx, I'm going to take a guess that you omitted the window/container as well. If you are using the 1.0 release, you can switch to one of the syntax options above. If you are on git master, the PR should be up shortly

Update: The PR can be found at https://github.com/swaywm/sway/pull/4069

@RedSoxFan thank you for the explanation. Both the window and container options work for me.

@RedSoxFan thanks! I saw the above explanation and tried a literal window|container, but not either of the options :S. This works, thanks for checking!
What's the difference between a container and a window? I can't find container in the man page or the wiki.

What's the difference between a container and a window

It's just an alias. The syntax comes from i3 and they allow either to be given. The bottom line is you can give either and get the same result. If you are on git master, you can also omit it since #4069 has been merged

I can't find container in the man page or the wiki.

The layout is a tree. You have the root, outputs, workspaces, and containers. The containers are children of the workspace. The branches are just for layout purposes and the leaves have views, which are the actual application windows

This assignment works for me, at least initially, but then Spotify changes its workspace sporadically on its own during usage. Is there a way to lock it to a workspace? for_window [class="Spotify"] move container to workspace $ws5 is what I'm using.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mcmfb picture mcmfb  路  3Comments

emersion picture emersion  路  4Comments

StephenBrown2 picture StephenBrown2  路  4Comments

RyanDwyer picture RyanDwyer  路  3Comments

ghost picture ghost  路  4Comments