Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions bin/omarchy-swap-monitors
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
# Rotate workspaces across all monitors in Hyprland/Omarchy

readonly APP_NAME="Omarchy"

dispatch() {
local output
if ! output=$(hyprctl dispatch "$@" 2>&1); then
notify-send "$APP_NAME" "hyprctl dispatch failed: $output"
exit 1
fi

if [[ "$output" != "ok" ]]; then
notify-send "$APP_NAME" "$output"
exit 1
fi
}

get_active_workspace() {
hyprctl monitors -j | jq -r ".[] | select(.name==\"$1\") | .activeWorkspace.id"
}

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

ORIGINAL_MONITOR=$(hyprctl monitors -j | jq -r '.[] | select(.focused == true) | .name')

if [[ -z "$ORIGINAL_MONITOR" || "$ORIGINAL_MONITOR" == "null" ]]; then
notify-send "$APP_NAME" "Could not detect the focused monitor."
exit 1
fi

# Validate that every monitor has an active workspace before rotating.
for mon in "${MONITORS[@]}"; do
ws=$(get_active_workspace "$mon")
if [[ -z "$ws" || "$ws" == "null" ]]; then
notify-send "$APP_NAME" "Could not detect workspace on $mon."
exit 1
fi
done

# Swap neighbouring monitors from right-to-left to rotate without creating temps.
for (( i=${#MONITORS[@]}-1; i>=1; i-- )); do
dispatch swapactiveworkspaces "${MONITORS[$((i-1))]}" "${MONITORS[$i]}"
done

# Ensure focus returns to the monitor the user was on.
dispatch focusmonitor "$ORIGINAL_MONITOR"

notify-send "$APP_NAME" "Rotated workspaces across ${#MONITORS[@]} monitors."
3 changes: 3 additions & 0 deletions default/hypr/bindings/utilities.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ bindd = SUPER CTRL, I, Toggle locking on idle, exec, omarchy-toggle-idle
# Toggle nightlight
bindd = SUPER CTRL, N, Toggle nightlight, exec, omarchy-toggle-nightlight

# Swap between monitors
bindd = SUPER CTRL, M, Swap monitors, exec, omarchy-swap-monitors

# Control Apple Display brightness
bindd = CTRL, F1, Apple Display brightness down, exec, omarchy-cmd-apple-display-brightness -5000
bindd = CTRL, F2, Apple Display brightness up, exec, omarchy-cmd-apple-display-brightness +5000
Expand Down