-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add monitor swap functionality #2303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
How does this work with a 3-monitor setup? |
This won't work because You'll need to add For a robust solution, dynamically detect monitors and iterate through them instead of hardcoding indices. No sane person uses more than 3 monitors anyway. |
I know :) I was just too lazy to point it out. Wanted contributor to think of this instead 👯 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this works:
#!/usr/bin/env bash
# Rotate workspaces across all monitors in Hyprland/Omarchy
readonly TMP_WORKSPACE=999
readonly APP_NAME="Omarchy"
mapfile -t MONITORS < <(hyprctl monitors -j | jq -r '.[].name')
if (( ${#MONITORS[@]} < 2 )); then
notify-send "$APP_NAME" "Only one monitor detected — nothing to rotate."
exit 0
fi
get_active_workspace() {
hyprctl monitors -j | jq -r ".[] | select(.name==\"$1\") | .activeWorkspace.id"
}
# Store all active workspaces
declare -a WORKSPACES
for mon in "${MONITORS[@]}"; do
ws=$(get_active_workspace "$mon")
if [[ -z "$ws" ]]; then
notify-send "$APP_NAME" "Could not detect workspace on $mon."
exit 1
fi
WORKSPACES+=("$ws")
done
# Move current workspace to temp
hyprctl dispatch workspace "$TMP_WORKSPACE"
hyprctl dispatch moveworkspacetomonitor "$TMP_WORKSPACE" "${MONITORS[0]}"
# Rotate: each monitor gets the workspace from the previous monitor
for (( i=${#MONITORS[@]}-1; i>=0; i-- )); do
prev_idx=$(( (i - 1 + ${#MONITORS[@]}) % ${#MONITORS[@]} ))
hyprctl dispatch moveworkspacetomonitor "${WORKSPACES[$prev_idx]}" "${MONITORS[$i]}"
done
# Focus the workspace that moved to the first monitor
hyprctl dispatch workspace "${WORKSPACES[-1]}"
notify-send "$APP_NAME" "Rotated workspaces across ${#MONITORS[@]} monitors."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omarchy-swap-monitors should go into the bin folder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested this last night. Works perfect on my 2 and 3 monitor setup.
# Ensure focus returns to the monitor the user was on. | ||
dispatch focusmonitor "$ORIGINAL_MONITOR" | ||
|
||
notify-send "$APP_NAME" "Rotated workspaces across ${#MONITORS[@]} monitors." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider to set timeouts on notifications
Description
Adds a new feature to swap active workspaces across all monitors in a circular pattern.
omarchy-swap-monitors
for circular workspace rotation across all monitors2025-10-07.19-29-43.mp4