dotfiles/de/home/.config/sway/scripts/exec-float
2025-12-31 11:30:02 -08:00

31 lines
1.4 KiB
Bash
Executable file

#!/bin/bash
eval "$1 &"
pid=$!
echo $pid
active_screen_dim="$(swaymsg -t get_outputs | jq -r '.. | select(.type?) | select(.focused==true).rect')"
active_screen_width="$(jq '.width' <<<${active_screen_dim})"
active_screen_height="$(jq '.height' <<<${active_screen_dim})"
if [[ "${active_screen_width}" -gt "${active_screen_height}" ]];then
win_height=$(( active_screen_height * 60 / 100 ))
win_width=$(( win_height * 175 / 100 ))
else
win_width=$(( active_screen_width * 60 / 100 ))
win_height=$(( win_width * 57 / 100 ))
fi
swaymsg "[pid=$pid]" "floating enable, resize set ${win_width}px ${win_height}px, move position center"
while [ "$?" = "2" ];do
swaymsg "[pid=$pid]" "floating enable, resize set ${win_width}px ${win_height}px, move position center"
done
swaymsg -t get_tree | jq ".. | select(.type?) | select(.pid==${pid})"
sleep 2
swaymsg -t get_tree | jq ".. | select(.type?) | select(.pid==${pid})"
exit
swaymsg -t get_tree | jq ".. | select(.type?) | select((.pid==${pid}) and (.type==\"floating_con\")).id" | grep ''
while [ "$?" = "1" ];do
swaymsg -t get_tree | jq ".. | select(.type?) | select((.pid==${pid}) and (.type==\"floating_con\")).id" | grep ''
done
#sleep 0.1
swaymsg "[pid=$pid]" "resize set ${win_width}px ${win_height}px, move position center"
#echo "floating enable, resize set ${win_width}px ${win_height}px"
#sleep 0.3;swaymsg -t get_tree | jq -r '.. | select(.type?) | select(.focused).window_rect'