# Shared launcher for the floating terminal sheets (#139). Used by waybar.nix # (nomarchy-calendar) and rofi.nix (the doctor sheet) — the classed Kitty # windows hyprland.nix floats and centers. # # Why the size lives here and not in a window rule: Hyprland 0.55.4 silently # ignores a *percentage* `size` rule. Measured on hardware 2026-07-16, both # rule orders, Kitty's own memory disabled so nothing could mask it: # `size 60% 65%` → the window keeps its requested size (no rule applied); # `size 1536 936` → lands exactly, in either order. No `hyprctl configerrors` # either way, which is how it survived the post-0.53 rule rewrite unnoticed. # # Absolute px is not a fix: "a fraction of the screen" is the whole intent, and # one px pair cannot serve a 2560x1440 desk monitor and the 1366x768 Acer that # is live QA (#131). A rule cannot compute it — the monitor is unknown at # eval time — so the sheet asks for its own size instead: read the focused # monitor here, hand Kitty the px, and let it request them. Those windows # therefore carry float/center rules and deliberately no `size` rule. { pkgs }: pkgs.writeShellScriptBin "nomarchy-term-sheet" '' set -u # usage: nomarchy-term-sheet [args...] [ "$#" -ge 4 ] || { echo "usage: nomarchy-term-sheet [args...]" >&2; exit 64; } cls="$1"; wpct="$2"; hpct="$3"; shift 3 # Hyprland reports the monitor in physical px plus the scale it renders at; # Kitty sizes in logical px, so divide before taking the fraction. A sheet # that opens at a clumsy size still beats no sheet, so every failure here # falls back rather than exits: no compositor (a TTY run), no jq answer, or # a nonsense answer all land on a size that fits the smallest panel we ship # on. dims=$(hyprctl monitors -j 2>/dev/null \ | ${pkgs.jq}/bin/jq -r --argjson w "$wpct" --argjson h "$hpct" ' [ .[] | select(.focused) ][0] | select(. != null) | (.scale // 1) as $s | select($s > 0) | "\((.width / $s * $w / 100) | floor) \((.height / $s * $h / 100) | floor)"' 2>/dev/null) || dims= width=''${dims%% *} height=''${dims##* } case "$width$height" in *[!0-9]*|"") width=800; height=500 ;; esac [ "$width" -ge 320 ] 2>/dev/null || width=800 [ "$height" -ge 240 ] 2>/dev/null || height=500 exec ${pkgs.kitty}/bin/kitty \ -o remember_window_size=no \ -o initial_window_width="$width" \ -o initial_window_height="$height" \ --class="$cls" -e "$@" ''