vitorpy's Dotfiles
1#!/usr/bin/env bash
2# Sway workspace navigation with auto-creation
3
4direction="$1" # "next" or "prev"
5
6# Get current workspace number
7current=$(swaymsg -t get_workspaces | jq -r '.[] | select(.focused==true) | .num')
8
9if [ "$direction" = "next" ]; then
10 next=$((current + 1))
11 swaymsg workspace number "$next"
12elif [ "$direction" = "prev" ]; then
13 if [ "$current" -gt 1 ]; then
14 prev=$((current - 1))
15 swaymsg workspace number "$prev"
16 fi
17fi