#!/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" while [ "$?" = "2" ];do swaymsg "[pid=$pid]" "floating enable, resize set ${win_width}px ${win_height}px" done swaymsg -t get_tree | jq ".. | select(.type?) | select((.pid==${pid}) and (.rect.height==${win_height} | not)).id" | grep '' while [ "$?" = "1" ];do swaymsg -t get_tree | jq ".. | select(.type?) | select((.pid==${pid}) and (.rect.height==${win_height} | not)).id" | grep '' done swaymsg "[pid=$pid]" "resize set ${win_width}px ${win_height}px, move position center"