Sway - assign workspaces

I’m trying to assign signal-desktop to open in it’s own workspace. I have an application_defaults config where I’m trying the following unsuccessfully …

assign [app_id=“signal-desktop”] 5
for_window [app_id=“signal-desktop”] focus

I’ll keep trying, thanks for any insight.

1 Like

Is signal running on Wayland? Otherwise it has no app_id.

Look at the config file of sway (.config/sway/config); in it you will find a section about assigning applications to workspaces.:

assign apps to workspaces

assign [app_id=“^brave-browser”] workspace number 1
assign [class=“^Vivaldi-stable”] workspace number 1
etc etc

That’s how i did it :wink:

Nextcloud Feel free to check out the files there.

1 Like

Thanks @Peppe

I have autotiling enabled, there could be interference there as none of the defined following workspaces work after installing and defining autotiling as an autostarp app. My assigned workspaces are …

Assign workspaces

assign [app_id=“firefox”] 2
for_window [app_id=“firefox”] focus

assign [class=“firefox”] 2
for_window [class=“firefox”] focus

assign [app_id=thunar] 3
for_window [app_id=thunar] focus

assign [class=“Telegram”] 4
for_window [class=“Telegram”] focus

assign [app_id=“signal-desktop”] workspace number 5
assign [class=“signal-desktop”] workspace number 5

for_window [app_id=“xed”] focus

Ah yes, that could be, I haven’t used it in a config like that (auto-tiling). Possibly someone else can shed a light

1 Like

Have you checked what the class or app_id for the application actually are? if it’s not working then you probably have it wrong.

2 Likes

By class or app_id, are you suggesting the actual program name via pacman -Ss?

via xprop.

Run xprop in the terminal, your cursor will turn to + symbol, then click on the window you need to find the app id for.

You will get a bit of an output in the terminal, for example. Firefox:

_NET_WM_USER_TIME(CARDINAL) = 7756823
GDK_TIMESTAMP_PROP(GDK_TIMESTAMP_PROP) = 0x61
WM_STATE(WM_STATE):
                window state: Normal
                icon window: 0x0
_NET_WM_BYPASS_COMPOSITOR(CARDINAL) = 2
WM_HINTS(WM_HINTS):
                Client accepts input or input focus: True
                Initial state is Normal State.
                bitmap id # to use for icon: 0x2a00031
                bitmap id # of mask for icon: 0x2a00038
                window id # of group leader: 0x2a00001
_GTK_THEME_VARIANT(UTF8_STRING) =
WM_WINDOW_ROLE(STRING) = "browser"
XdndAware(ATOM) = BITMAP
_NET_WM_OPAQUE_REGION(CARDINAL) = 0, 0, 2091, 2094
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL
_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 44040239, 44040240
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x2a0002e
WM_CLIENT_LEADER(WINDOW): window id # 0x2a00001
_NET_WM_PID(CARDINAL) = 34510
WM_LOCALE_NAME(STRING) = "en_NZ.UTF-8"
WM_CLIENT_MACHINE(STRING) = "machine"
WM_NORMAL_HINTS(WM_SIZE_HINTS):
                program specified minimum size: 500 by 133
                program specified maximum size: 16384 by 16384
                program specified base size: 500 by 133
                window gravity: NorthWest
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST
WM_CLASS(STRING) = "Navigator", "firefox"
WM_ICON_NAME(COMPOUND_TEXT) = "Sway - assign workspaces - Technical Issues & Assistance / Sway, Wayland, wlroots - ArchLabs Linux — Mozilla Firefox"
_NET_WM_ICON_NAME(UTF8_STRING) = "Sway - assign workspaces - Technical Issues & Assistance / Sway, Wayland, wlroots - ArchLabs Linux — Mozilla Firefox"
WM_NAME(COMPOUND_TEXT) = "Sway - assign workspaces - Technical Issues & Assistance / Sway, Wayland, wlroots - ArchLabs Linux — Mozilla Firefox"
_NET_WM_NAME(UTF8_STRING) = "Sway - assign workspaces - Technical Issues & Assistance / Sway, Wayland, wlroots - ArchLabs Linux — Mozilla Firefox"

I run this in place of xprop which gives a much more to the point result:

xprop | awk -F\"'" '/CLASS/ {printf \"NAME = %s\nCLASS = %s\n\", \$2, \$4}

Using this with Firefox gives me:

NAME = Navigator
CLASS = firefox

Some definitions or translations of the output are as folllows:

WM_CLASS(STRING) = instance, class
WM_NAME(STRING) = title
WM_WINDOW_ROLE(STRING) = role
_NET_WM_WINDOW_TYPE(ATOM) = wintype

I hope this makes sense, I’m not sure what definition Swa requires (whether it’s class, instance or role) but using Xprop will help.

4 Likes

Thanks for your time & detail @Dobbie03

This did the trick …

assign [class=“Signal”] 5
assign [app_id=“signal”] focus

2 Likes

xprop as the name suggests is an xorg application which can work in Wayland through xwayland but shouldn’t be relied on. Sway and other wayland compositors usually provide a way of querying current windows.

4 Likes

swaymsg” is the utility to query app_id of a running window in sway.

$swaymsg -p -t get_tree | grep app_id                                                                                                           
              "app_id": "foot",
              "app_id": "firefox",
              "app_id": "pcmanfm",
6 Likes

Top @chroot

1 Like

Quite helpful as well @chroot. :+1:

1 Like

True, I forget that Sway is Wayland based.

@GreenMartian ignore my “advice” for Wayland based wm’s

2 Likes

Let’s chaulk it up as good advice all around @Dobbie03:grinning:

2 Likes

Maybe but not in this case :smiley:

Thanks though.

1 Like