dotfiles/.config/waybar/scripts/apply_grid_layout.sh
2025-05-28 18:27:10 +02:00

38 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# Obtiene las ventanas abiertas en el espacio de trabajo actual
windows=$(hyprctl clients -j | jq -r '.[] | .address')
# Cuenta las ventanas abiertas
window_count=$(echo "$windows" | wc -l)
# Define las posiciones y tamaños de cada ventana según la cuadrícula
case $window_count in
1)
hyprctl dispatch movewindow 50% 50% resizewindowpixel 100% 100% ;;
2)
hyprctl dispatch focuswindow $(echo "$windows" | sed -n 1p)
hyprctl dispatch movewindow 0 0 resizewindowpixel 50% 100%
hyprctl dispatch focuswindow $(echo "$windows" | sed -n 2p)
hyprctl dispatch movewindow 50% 0 resizewindowpixel 50% 100% ;;
3)
# Configura tres ventanas, dos arriba y una en la mitad inferior
hyprctl dispatch focuswindow $(echo "$windows" | sed -n 1p)
hyprctl dispatch movewindow 0 0 resizewindowpixel 50% 50%
hyprctl dispatch focuswindow $(echo "$windows" | sed -n 2p)
hyprctl dispatch movewindow 50% 0 resizewindowpixel 50% 50%
hyprctl dispatch focuswindow $(echo "$windows" | sed -n 3p)
hyprctl dispatch movewindow 0 50% resizewindowpixel 100% 50% ;;
4)
# Configura cuatro ventanas en una cuadrícula de 2x2
hyprctl dispatch focuswindow $(echo "$windows" | sed -n 1p)
hyprctl dispatch movewindow 0 0 resizewindowpixel 50% 50%
hyprctl dispatch focuswindow $(echo "$windows" | sed -n 2p)
hyprctl dispatch movewindow 50% 0 resizewindowpixel 50% 50%
hyprctl dispatch focuswindow $(echo "$windows" | sed -n 3p)
hyprctl dispatch movewindow 0 50% resizewindowpixel 50% 50%
hyprctl dispatch focuswindow $(echo "$windows" | sed -n 4p)
hyprctl dispatch movewindow 50% 50% resizewindowpixel 50% 50% ;;
esac