Skip to content

Workspace next/previous cycle back to start/end #1115

@williamgrimes

Description

@williamgrimes

Is your feature request related to a problem? Please describe.
Frequently I switch workspace with alt + tab and shift + alt + tab which invokes the next-workspace and previous-workspace. I frequently overshoot the workspace I am looking for and next/previous cycles back to the start/end of the list.

Describe the solution you'd like
I would like to have the option for next-workspace to stop at the last workspace, and previous-workspace to stop at the first workspace, so I can easily go back and forth between using the first and last as an anchor. The cycling back is confusing and I really dislike this behavior.

Describe alternatives you've considered
I tried creating to bash scripts and binding them to alt+tab and `shift+alt+tab e.g.

i3-next-workspace-no-cycle.sh

#!/bin/bash

# Get the number of the current workspace
current=$(i3-msg -t get_workspaces | jq '.[] | select(.focused==true).num')

# Find the highest workspace number
max=$(i3-msg -t get_workspaces | jq '.[] | .num' | sort -rn | head -1)

# Move to the next workspace only if we're not on the last workspace
if [ "$current" -lt "$max" ]; then
    i3-msg workspace next_on_output
fi

and

i3-prev-workspace-no-cycle.sh

#!/bin/bash

# Get the number of the current workspace
current=$(i3-msg -t get_workspaces | jq '.[] | select(.focused==true).num')

# Find the lowest workspace number
min=$(i3-msg -t get_workspaces | jq '.[] | .num' | sort -n | head -1)

# Move to the previous workspace only if we're not on the first workspace
if [ "$current" -gt "$min" ]; then
    i3-msg workspace prev_on_output
fi

This introduced some unusual behaviour and I could not get it to work correctly.

Any guidance would be appreciated to achieve this as simply as possible.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestneeds-triageAny bug that requires classification by a contributor

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions