Skip to content

"move workspace" does not behave as expected for an empty workspace #5388

Description

@RulentWave

sway version 1.4
If an empty workspace exists, such as on another monitor, attempting to move the workspace via IPC to another output does not work. The workspace stays on that output.

this can be tested with my script meant to swap workspaces on outputs. This works as expected as long as the target workspace is not empty. If it is empty, the workspace never changes outputs. The behavior is the same if I use swaymsg via wofi on an empty workspace

#!/usr/bin/env python
import asyncio
from i3ipc.aio import Connection
from sys import argv
async def main():
    i3 =  await Connection().connect()
    outputs = await i3.get_outputs()
    workspaces = await i3.get_workspaces()
    target_workspace = None

    for output in outputs:
        if output.focused == True:
            focused_output = output
    for workspace in workspaces:
        if str(workspace.num) == argv[1]:
            target_workspace = workspace
        if workspace.output == focused_output.name:
            prev_workspace = workspace

    # if the target workspace doesn't exist, create it
    if target_workspace == None:
        await i3.command('workspace ' + argv[1])
    else:
        # Move target workspace to focused output
        await i3.command('workspace ' + str(target_workspace.num) + '; move workspace to output ' + focused_output.name + '; workspace ' + str(target_workspace.num))
    # move previous workspace to target workspace's output
        await i3.command ('workspace ' + str(prev_workspace.num) + '; move workspace to output ' + target_workspace.output + '; workspace ' + str(prev_workspace.num))
    # focus target workspace at the new output
        await i3.command ('workspace ' + str(target_workspace.num))

asyncio.run(main())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions