Better workspace switcher for multi-monitor setups
If you're running a multi-monitor setup in omarchy and want to cycle through workspaces on each monitor independently using a mouse button or keybind, the built-in dispatchers don't quite cut it:
- workspace e+1 cycles through all workspaces across all monitors
- focusworkspaceoncurrentmonitor still pulls workspaces assigned to other monitors
So I put together a small script that only cycles through workspaces already on the active monitor, and opens a fresh empty workspace if there's only one.
Open up a terminal and paste the following:
cat > ~/.local/bin/workspace-cycle.sh << 'EOF'
#!/bin/bash
DIRECTION=$1 # "next" or "prev"
# Get active monitor and its current workspace
MONITOR=$(hyprctl monitors -j | jq -r '.[] | select(.focused == true)')
CURRENT=$(echo $MONITOR | jq -r '.activeWorkspace.id')
MONITOR_NAME=$(echo $MONITOR | jq -r '.name')
# Get all workspaces on this monitor, sorted
WORKSPACES=$(hyprctl workspaces -j | jq -r --arg m "$MONITOR_NAME" \
'[.[] | select(.monitor == $m)] | sort_by(.id) | .[].id')
IDS=($WORKSPACES)
COUNT=${#IDS[@]}
# If only one workspace on this monitor, open a new empty one
if [ "$COUNT" -le 1 ]; then
hyprctl dispatch workspace empty
exit 0
fi
# Find next/prev in list
for i in "${!IDS[@]}"; do
if [ "${IDS[$i]}" = "$CURRENT" ]; then
if [ "$DIRECTION" = "next" ]; then
TARGET=${IDS[$(( (i + 1) % COUNT ))]}
else
TARGET=${IDS[$(( (i - 1 + COUNT) % COUNT ))]}
fi
hyprctl dispatch workspace $TARGET
break
fi
done
EOF
chmod +x ~/.local/bin/workspace-cycle.sh
Then add to your ~/.config/hypr/bindings.conf:
bind = SHORTCUT_KEY1, SHORTCUT_KEY2, exec, ~/.local/bin/workspace-cycle.sh next
bind = SHORTCUT_KEY1, SHORTCUT_KEY2, exec, ~/.local/bin/workspace-cycle.sh prev
Not sure what your shortcut key/mouse button is called? Run wev and press it to find out.