38 lines
1 KiB
Bash
Executable file
38 lines
1 KiB
Bash
Executable file
#!/bin/bash
|
||
hyprctl monitors > /dev/null || { echo "Hyprland IPC not available"; exit 1; }
|
||
|
||
focused_win_id=$(hyprctl activewindow -j | jq -r '.id')
|
||
|
||
new_win_id=$1
|
||
|
||
if [ -z "$focused_win_id" ] || [ -z "$new_win_id" ]; then
|
||
echo "Missing window IDs"
|
||
exit 1
|
||
fi
|
||
|
||
# Get all windows on current workspace
|
||
workspace_id=$(hyprctl activewindow -j | jq -r '.workspace.id')
|
||
|
||
windows=($(hyprctl clients -j | jq -r --arg ws "$workspace_id" '.[] | select(.workspace.id==$ws) | .id'))
|
||
|
||
# Find focused window index
|
||
idx=-1
|
||
for i in "${!windows[@]}"; do
|
||
if [[ "${windows[$i]}" == "$focused_win_id" ]]; then
|
||
idx=$i
|
||
break
|
||
fi
|
||
done
|
||
|
||
# If focused window not found, just bail
|
||
if [[ $idx -eq -1 ]]; then
|
||
exit 0
|
||
fi
|
||
|
||
# Move new window right after focused window in stack order
|
||
# Hyprland doesn’t support direct stack manipulation via IPC yet,
|
||
# but you can focus new window and then focus focused_win again
|
||
# to simulate the "attach aside" effect in focus order.
|
||
|
||
hyprctl dispatch focuswindow "$new_win_id"
|
||
hyprctl dispatch focuswindow "$focused_win_id"
|