feat(displays): display profiles — docked/undocked switching (item 15a)
All checks were successful
Check / eval (push) Successful in 3m4s
All checks were successful
Check / eval (push) Successful in 3m4s
nomarchy.displayProfiles: named layouts for the same outputs, each a list of nomarchy.monitors-style entries. The active profile lives in the in-flake state (settings.displayProfile) on the night-light pattern: nomarchy-display-profile apply <name> fires the baked hyprctl rules instantly and writes the state with --no-switch; the next rebuild bakes the profile's entries over nomarchy.monitors whole-by-name. Monitor-rule composition is extracted to pure monitor-rules.nix (renderer + 3-layer resolve, incl. a disable-guard so a stale menu resolution pick can't resurrect a profile-disabled panel, and junk state degrading to base config instead of an eval error) — because a writeText/toFile state fixture is unreadable at flake-check eval time, the new checks.display-profiles unit-tests the pure function directly. Menu: System › Display gains a self-gated "Profiles ›" row (●/○ active mark, Base layout to clear); commented template example + README row. Verified: V0 (flake check, forcing the new check's asserts); V1 — a scratch downstream through lib.mkFlake builds: the generated tool passes bash -n with correct rules (disable/vrr/float scale), the baked hyprland.conf shows the exact expected overlay, the menu renders, and list/usage smoke-test clean. Remains: V3 live switching on a dock (HARDWARE-QUEUE). Slices b (hotplug auto-switch) + c (workspace binding) stay in item 15. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -303,13 +303,17 @@ ${themeRows}
|
||||
|| { notify-send "Display" "Hyprland is not running."; exit 0; }
|
||||
mons=$(hyprctl monitors -j)
|
||||
|
||||
# Choose the output (skip the chooser when only one is connected).
|
||||
if [ "$(printf '%s' "$mons" | jq -r '.[].name' | grep -c .)" -gt 1 ]; then
|
||||
# Choose the output (skip the chooser when only one is connected and
|
||||
# there are no profiles — the Profiles row needs the chooser to live in).
|
||||
profs=; command -v nomarchy-display-profile >/dev/null 2>&1 && profs=1
|
||||
if [ -n "$profs" ] || [ "$(printf '%s' "$mons" | jq -r '.[].name' | grep -c .)" -gt 1 ]; then
|
||||
name=$( {
|
||||
[ -n "$profs" ] && printf 'Profiles ›\n'
|
||||
printf '%s' "$mons" | jq -r '.[] | "\(.name) · \(.width)x\(.height)@\(.refreshRate|round)Hz"'
|
||||
printf '%s\n' "$BACK"
|
||||
} | rofi -dmenu -p Display ) || exit 0
|
||||
[ "$name" = "$BACK" ] && exec "$0" system
|
||||
[ "$name" = "Profiles ›" ] && exec "$0" display-profile
|
||||
name=''${name%% ·*} # strip the " · WxH@R" hint
|
||||
else
|
||||
name=$(printf '%s' "$mons" | jq -r '.[0].name')
|
||||
@@ -377,6 +381,27 @@ ${themeRows}
|
||||
*"Record screen"*) exec nomarchy-record start screen ;;
|
||||
esac ;;
|
||||
|
||||
display-profile)
|
||||
# Named multi-output layouts (nomarchy.displayProfiles). Applying is
|
||||
# instant (hyprctl per entry, via nomarchy-display-profile) and
|
||||
# persisted in-flake (settings.displayProfile) so the next rebuild
|
||||
# bakes it. "Base layout" clears the state and hyprctl-reloads.
|
||||
command -v nomarchy-display-profile >/dev/null 2>&1 \
|
||||
|| { notify-send "Display profiles" "None declared (nomarchy.displayProfiles)."; exit 0; }
|
||||
active=$(nomarchy-display-profile active)
|
||||
choice=$( {
|
||||
nomarchy-display-profile list | while IFS= read -r p; do
|
||||
if [ "$p" = "$active" ]; then printf '● %s\n' "$p"; else printf '○ %s\n' "$p"; fi
|
||||
done
|
||||
printf 'Base layout\n'
|
||||
printf '%s\n' "$BACK"
|
||||
} | rofi -dmenu -p Profiles ) || exit 0
|
||||
case "$choice" in
|
||||
"$BACK") exec "$0" display ;;
|
||||
"Base layout") exec nomarchy-display-profile base ;;
|
||||
*) exec nomarchy-display-profile apply "''${choice#[●○] }" ;;
|
||||
esac ;;
|
||||
|
||||
colorpicker)
|
||||
# Pick a pixel's color (hyprpicker's zoom loupe) → clipboard, hex
|
||||
# in the confirmation toast. Esc/cancel exits silently. Self-gated
|
||||
@@ -610,7 +635,7 @@ ${themeRows}
|
||||
esac ;;
|
||||
|
||||
*)
|
||||
echo "usage: nomarchy-menu [tools|system|power|power-profile|theme|clipboard|calc|files|emoji|web|network|bluetooth|audio|display|printers|capture|colorpicker|keybinds|ask|dnd|nightlight|autotimezone|autocommit|vpn|snapshot]" >&2
|
||||
echo "usage: nomarchy-menu [tools|system|power|power-profile|theme|clipboard|calc|files|emoji|web|network|bluetooth|audio|display|display-profile|printers|capture|colorpicker|keybinds|ask|dnd|nightlight|autotimezone|autocommit|vpn|snapshot]" >&2
|
||||
exit 64 ;;
|
||||
esac
|
||||
'';
|
||||
|
||||
Reference in New Issue
Block a user