From 55ed0d89d3ae20f3d4ed041a29e1e92b76097e91 Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Wed, 26 Aug 2026 09:58:55 -0400 Subject: [PATCH] feat(cli): add omarchy-toggle-layout executable --- .../bin/executable_omarchy-toggle-layout | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 dot_local/bin/executable_omarchy-toggle-layout diff --git a/dot_local/bin/executable_omarchy-toggle-layout b/dot_local/bin/executable_omarchy-toggle-layout new file mode 100755 index 0000000..f3e118e --- /dev/null +++ b/dot_local/bin/executable_omarchy-toggle-layout @@ -0,0 +1,41 @@ +#!/bin/bash + +# omarchy:summary=Toggle the workspace layout, and set every column to one width when it becomes scrolling +# omarchy:args=[width] + +set -uo pipefail + +# Column width, as a fraction of the screen, applied to every column on the +# workspace when it turns to scrolling. +WIDTH="${1:-0.75}" + +hypr_dispatch() { + local lua="$1" + shift + + hyprctl dispatch "$lua" >/dev/null 2>&1 || hyprctl dispatch "$@" >/dev/null +} + +current_layout() { + hyprctl activeworkspace -j 2>/dev/null | jq -r '.tiledLayout // empty' +} + +omarchy-hyprland-workspace-layout-toggle || exit 1 + +# The toggle writes a workspace rule, so the new layout can take a moment to +# show up. Read until it does, then act only on the scrolling case: dwindle +# re-tiles on its own and needs no widths. +for _ in {1..6}; do + case "$(current_layout)" in + scrolling) + MSG="colresize all $WIDTH" + hypr_dispatch "hl.dsp.layout(\"$MSG\")" layoutmsg "$MSG" + exit 0 + ;; + dwindle) + exit 0 + ;; + esac + + sleep 0.05 +done