#!/bin/bash active_window_type="$(swaymsg -t get_tree | jq -r '.. | select(.type?) | select(.focused==true).type')" swaymsg floating toggle if [[ "${active_window_type}" == "con" ]];then 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 #landscape win_height=$(( active_screen_height * 60 / 100 )) win_width=$(( win_height * 175 / 100 )) else #portrait win_width=$(( active_screen_width * 60 / 100 )) win_height=$(( win_width * 57 / 100 )) fi swaymsg resize set "${win_width}px" "${win_height}px" fi