This script will cycle through all workspaces, and will wrap to the first workspace when the last workspace is reached or will wrap to the last workspace when the first workspace is reached. This allows for seamless navigation of workspaces.
#!/bin/bash
current="$(niri msg -j workspaces | jq ".[] | select(.is_focused == true ) | .idx")"
count="$(niri msg -j workspaces | jq "[.[] | select(.is_urgent == false|true )] | length")"
moveTo=0;
if [[ $@ == 'right' ]] then
moveTo=$(($current+1))
if [[ $moveTo -gt $count ]] then
moveTo=1
fi
fi
if [[ $@ == 'left' ]] then
moveTo=$(($current-1))
if [[ $moveTo -eq 0 ]] then
moveTo=$count
fi
fi
move=$(niri msg action focus-workspace $moveTo)