dotfiles/local/bin/shishi.sh
2025-07-21 12:57:44 +03:30

38 lines
1 KiB
Bash
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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 doesnt 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"