fix(ui): #139 sheets size themselves; #141 waybar clicks stop reading the env
Some checks failed
Check / eval (push) Has been cancelled

#139 — calcurse/doctor floated full-screen. Two faults stacked, which is
why it looked like the float rules were dead:
  1. Hyprland 0.55.4 silently ignores percentage `size` rules. Matrix on
     hardware (both orders, kitty memory off): `size 60% 65%` never
     applies, `size 1536 936` applies either way, configerrors empty both
     times. Rule order was a red herring.
  2. Kitty defaults to remember_window_size=yes and replays the last OS
     window's size into every float — so after a tiled terminal, a sheet
     opens maximized. This is the Ghostty regression: Ghostty had no such
     memory, so fault 1 stayed invisible until #95.

Fix: remember_window_size=no (floats must be deterministic) and the sheets
ask for their own size — term-sheet.nix reads the focused monitor and
hands kitty the px, because px in a rule cannot mean "a fraction of *this*
screen" and one pair cannot serve 2560x1440 and the 1366x768 Acer (#131).
Those windows keep float/center and deliberately carry no size rule.

#141 — the updates click did nothing: whole-swaps hand-wrote
`sh -c '$TERMINAL …'` and Waybar has no TERMINAL (home.sessionVariables →
login shells only; the bar is spawned by Hyprland). Fixed at the root:
`nomarchy-updates upgrade-window` opens its own window, so all five call
sites name one env-free command and a theme file stops having an opinion
about terminals. checks.waybar-swap-env guards the class.

Bernardo asked mid-task for the update window to float — it is now the
third caller of the sheet helper (com.nomarchy.updates, 45%x50%).

V3 on the dev box: calendar 1536x936, doctor 1408x1008, updates 1152x720
— exactly the intended fractions, floating and centred; #141 driven under
`env -i` with no TERMINAL, matching Waybar's real environment; the guard
proven by reintroducing the bug. Acer V3 queued.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-16 10:04:28 +01:00
parent 4a63f27bf4
commit 55a516e1c7
15 changed files with 220 additions and 74 deletions

View File

@@ -1060,16 +1060,22 @@ in
# Calendar popup (item 42): nomarchy-calendar → calcurse in a
# kitty window tagged with a distinct --class, so it floats centered.
# No `size` rule on purpose: a percentage one is silently ignored here
# (#139, measured on hardware — see term-sheet.nix), and px cannot mean
# "a fraction of *this* monitor". The launcher sizes the window itself.
"float 1, match:class ^(com\\.nomarchy\\.calendar)$"
"size 60% 65%, match:class ^(com\\.nomarchy\\.calendar)$"
"center 1, match:class ^(com\\.nomarchy\\.calendar)$"
# Doctor sheet (System Doctor / Waybar custom/doctor click):
# nomarchy-menu doctor → kitty --class=com.nomarchy.doctor.
# nomarchy-menu doctor → nomarchy-term-sheet, sized the same way.
"float 1, match:class ^(com\\.nomarchy\\.doctor)$"
"size 55% 70%, match:class ^(com\\.nomarchy\\.doctor)$"
"center 1, match:class ^(com\\.nomarchy\\.doctor)$"
# Upgrade prompt (Waybar custom/updates click → nomarchy-updates
# upgrade-window): the same classed sheet, smaller — it is a y/N flow.
"float 1, match:class ^(com\\.nomarchy\\.updates)$"
"center 1, match:class ^(com\\.nomarchy\\.updates)$"
# Polkit auth (hyprpolkitagent — app id / binary name in the package)
# and pinentry-qt (keys.nix default; org.gnupg.pinentry-qt desktop).
# workspace current: agent was started on ws1 at login; without this

View File

@@ -47,6 +47,14 @@ in
wayland_titlebar_color = lib.mkDefault "background";
# Fresh windows for doctor/calendar --class launches (not one shared instance).
single_instance = lib.mkDefault false;
# Kitty's default is to remember the last OS window's size and replay it
# into the next one (~/.cache/kitty/main.json). Harmless while tiled —
# the compositor sizes those — but every *floating* kitty then inherits
# whatever the last window happened to be, so a sheet opened after a
# maximized terminal opens maximized (#139: the Ghostty regression, which
# kept no such memory). Floats should be deterministic: each launcher
# asks for the size it wants.
remember_window_size = lib.mkDefault false;
} // colorSettings);
};
}

View File

@@ -11,6 +11,7 @@ let
cfg = config.nomarchy;
t = cfg.theme;
c = t.colors;
termSheet = import ./term-sheet.nix { inherit pkgs; };
inherit (config.lib.formats.rasi) mkLiteral;
px = n: mkLiteral "${toString n}px";
@@ -1043,9 +1044,10 @@ ${themeRows}
doctor)
# Read-only health sheet in a floating, centered kitty window
# (class matched by hyprland.nix windowrules). Same pattern as
# nomarchy-calendar. Exit code doesn't matter; the sheet is the product.
exec kitty --class=com.nomarchy.doctor \
-e sh -c "nomarchy-doctor
# nomarchy-calendar, sizing itself for the same reason (#139).
# Exit code doesn't matter; the sheet is the product.
exec ${termSheet}/bin/nomarchy-term-sheet com.nomarchy.doctor 55 70 \
sh -c "nomarchy-doctor
printf '\nEnter to close.'; read -r _" ;;
firmware)

View File

@@ -0,0 +1,52 @@
# 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 <class> <width%> <height%> <cmd> [args...]
[ "$#" -ge 4 ] || { echo "usage: nomarchy-term-sheet <class> <w%> <h%> <cmd> [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 "$@"
''

View File

@@ -14,6 +14,7 @@
let
cfg = config.nomarchy.updates;
termSheet = import ./term-sheet.nix { inherit pkgs; };
nomarchy-updates = pkgs.writeShellScriptBin "nomarchy-updates" ''
set -u
@@ -113,7 +114,23 @@ let
fi
"$0" check
echo "Done press enter."; read -r _ || true ;;
*) echo "usage: nomarchy-updates [check|status|upgrade]" >&2; exit 64 ;;
upgrade-window)
# The Waybar click target. `upgrade` prompts, so it needs a terminal
# and the bar has none: it is spawned by Hyprland, whose environment has
# no $TERMINAL (that is a home.sessionVariables entry, so only login
# shells see it). A whole-swap's hand-written on-click that reached for
# $TERMINAL expanded to nothing and the click silently did nothing
# (#141). Opening our own window is the fix that cannot rot: every
# caller generated module and whole-swap alike names one env-free
# command, and a theme file stops having an opinion about terminals.
#
# A classed sheet like the calendar and doctor: a short y/N flow has no
# business taking the whole screen, and the class is what hyprland.nix
# floats it by. Smaller than either (45%x50%) this is a prompt, not a
# document.
exec ${termSheet}/bin/nomarchy-term-sheet com.nomarchy.updates 45 50 \
"$0" upgrade ;;
*) echo "usage: nomarchy-updates [check|status|upgrade|upgrade-window]" >&2; exit 64 ;;
esac
'';
in

View File

@@ -11,6 +11,7 @@
let
t = config.nomarchy.theme;
termSheet = import ./term-sheet.nix { inherit pkgs; };
# Whether the keyboard-layout indicator is worth bar space, and the filter
# that holds a whole-swap to the same answer. Contract + rationale (and
@@ -95,13 +96,14 @@ let
# Opens calcurse (lightweight TUI calendar) in a floating, centered kitty
# window — Waybar clock on-click. Distinct --class → hyprland.nix float
# rules. Kitty is always installed (kitty.nix).
# rules. Kitty is always installed (kitty.nix). The sheet sizes itself
# (#139: a percentage `size` rule is silently ignored) — see term-sheet.nix.
calendarLauncher = pkgs.writeShellScriptBin "nomarchy-calendar" ''
if ! command -v calcurse >/dev/null 2>&1; then
notify-send "Calendar" "calcurse isn't installed (removed from home.packages?)." 2>/dev/null
exit 0
fi
exec kitty --class=com.nomarchy.calendar -e calcurse
exec ${termSheet}/bin/nomarchy-term-sheet com.nomarchy.calendar 60 65 calcurse
'';
# VPN indicator — shows a shield when a NetworkManager VPN/WireGuard
@@ -353,7 +355,7 @@ let
return-type = "json";
interval = 1800;
signal = 9;
on-click = "${config.nomarchy.terminal} -e nomarchy-updates upgrade";
on-click = "nomarchy-updates upgrade-window";
};
# swaync notification bell + Do-Not-Disturb state. `-swb` streams JSON