#!/bin/bash # NOTE: with the Lua config, `hyprctl dispatch` evaluates Lua (hl.dispatch(...)), # not the old hyprlang "togglefloating" / "resizeactive exact 70% 70%" strings. # The Lua resize dispatcher only takes absolute x/y, so the percentage is # resolved here against the logical size of the window's monitor. PERCENT=70 eval "$(hyprctl activewindow -j | jq -r '"floating=\(.floating) fullscreen=\(.fullscreen) mon=\(.monitor)"')" if [ "$floating" = "true" ]; then hyprctl dispatch 'hl.dsp.window.float()' exit fi read -r w h <<<"$(hyprctl monitors -j | jq -r --argjson m "$mon" --argjson p "$PERCENT" \ '.[] | select(.id == $m) | "\((.width / .scale * $p / 100) | round) \((.height / .scale * $p / 100) | round)"')" # resizeactive is a no-op on a fullscreen window, so leave fullscreen first. if [ "$fullscreen" != "0" ]; then hyprctl dispatch 'hl.dsp.window.fullscreen({ mode = "fullscreen" })' fi hyprctl --batch "dispatch hl.dsp.window.float(); dispatch hl.dsp.window.resize({ x = ${w}, y = ${h} }); dispatch hl.dsp.window.center()"