From 528a4343a928227b01837b6eb3da70ae1428f74e Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 24 Jul 2026 12:28:55 -0700 Subject: [PATCH] Add omarchy-hyprland-monitor-laptop for internal display lookup Co-Authored-By: Claude Opus 5 (1M context) --- bin/omarchy-hyprland-monitor-clamshell | 2 +- bin/omarchy-hyprland-monitor-internal | 3 +-- bin/omarchy-hyprland-monitor-internal-mirror | 5 ++--- bin/omarchy-hyprland-monitor-laptop | 5 +++++ test/shell.d/monitor-recovery-test.sh | 4 +++- 5 files changed, 12 insertions(+), 7 deletions(-) create mode 100755 bin/omarchy-hyprland-monitor-laptop diff --git a/bin/omarchy-hyprland-monitor-clamshell b/bin/omarchy-hyprland-monitor-clamshell index a8459369..2efbc36b 100755 --- a/bin/omarchy-hyprland-monitor-clamshell +++ b/bin/omarchy-hyprland-monitor-clamshell @@ -8,7 +8,7 @@ CLAMSHELL_FLAG="$TOGGLES_DIR/internal-monitor-clamshell.lua" MANUAL_DISABLE_FLAG="$TOGGLES_DIR/internal-monitor-disable.lua" SCALE_STATE="$TOGGLES_DIR/internal-monitor-scale" -INTERNAL=$(hyprctl monitors all -j | jq -r '.[] | select(.name | test("^(eDP|LVDS|DSI)-")).name' | head -n 1) +INTERNAL=$(omarchy-hyprland-monitor-laptop) valid_scale() { [[ $1 =~ ^[0-9]+([.][0-9]+)?$ ]] diff --git a/bin/omarchy-hyprland-monitor-internal b/bin/omarchy-hyprland-monitor-internal index 9916f95c..836073ee 100755 --- a/bin/omarchy-hyprland-monitor-internal +++ b/bin/omarchy-hyprland-monitor-internal @@ -7,8 +7,7 @@ TOGGLE="internal-monitor-disable" TOGGLE_FLAG="$HOME/.local/state/omarchy/toggles/hypr/$TOGGLE.lua" MIRROR_TOGGLE="internal-monitor-mirror" -# Get internal monitor name dynamically, including disabled outputs. -INTERNAL=$(hyprctl monitors all -j | jq -r '.[] | select(.name | test("^(eDP|LVDS|DSI)-")).name' | head -n 1) +INTERNAL=$(omarchy-hyprland-monitor-laptop) wake() { hyprctl dispatch 'hl.dsp.dpms({ action = "enable" })' >/dev/null 2>&1 || true diff --git a/bin/omarchy-hyprland-monitor-internal-mirror b/bin/omarchy-hyprland-monitor-internal-mirror index 57531d25..d5213d4c 100755 --- a/bin/omarchy-hyprland-monitor-internal-mirror +++ b/bin/omarchy-hyprland-monitor-internal-mirror @@ -7,9 +7,8 @@ TOGGLE="internal-monitor-mirror" TOGGLE_FLAG="$HOME/.local/state/omarchy/toggles/hypr/$TOGGLE.lua" DISABLE_TOGGLE="internal-monitor-disable" -# Get names dynamically -INTERNAL=$(hyprctl monitors -j | jq -r '.[] | select(.name | test("^(eDP|LVDS|DSI)-")).name' | head -n 1) -# Get the first available external monitor +INTERNAL=$(omarchy-hyprland-monitor-laptop) +# The first active external monitor EXTERNAL=$(hyprctl monitors -j | jq -r '.[] | select(.name | test("^(eDP|LVDS|DSI)-") | not).name' | head -n 1) on() { diff --git a/bin/omarchy-hyprland-monitor-laptop b/bin/omarchy-hyprland-monitor-laptop new file mode 100755 index 00000000..cc0a254f --- /dev/null +++ b/bin/omarchy-hyprland-monitor-laptop @@ -0,0 +1,5 @@ +#!/bin/bash + +# omarchy:summary=Print the name of the built-in laptop display, including disabled outputs. + +hyprctl monitors all -j | jq -r '.[] | select(.name | test("^(eDP|LVDS|DSI)-")).name' | head -n 1 diff --git a/test/shell.d/monitor-recovery-test.sh b/test/shell.d/monitor-recovery-test.sh index 18cab29b..c455fe75 100755 --- a/test/shell.d/monitor-recovery-test.sh +++ b/test/shell.d/monitor-recovery-test.sh @@ -7,6 +7,7 @@ source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh" monitor_watch="$ROOT/bin/omarchy-hyprland-monitor-watch" monitor_internal="$ROOT/bin/omarchy-hyprland-monitor-internal" monitor_mirror="$ROOT/bin/omarchy-hyprland-monitor-internal-mirror" +monitor_laptop="$ROOT/bin/omarchy-hyprland-monitor-laptop" monitor_external_active="$ROOT/bin/omarchy-hyprland-monitor-external-active" sleep_lock="$ROOT/bin/omarchy-system-sleep-lock" system_wake="$ROOT/bin/omarchy-system-wake" @@ -60,7 +61,8 @@ grep -F 'omarchy-hw-clamshell' "$clamshell" >/dev/null pass "clamshell monitor sync disables laptop output and force-recovers it" grep -F "hyprctl dispatch 'hl.dsp.dpms({ action = \"enable\" })' >/dev/null 2>&1 || true" "$monitor_internal" >/dev/null -grep -F 'hyprctl monitors all -j' "$monitor_internal" >/dev/null +grep -F 'omarchy-hyprland-monitor-laptop' "$monitor_internal" >/dev/null +grep -F 'hyprctl monitors all -j' "$monitor_laptop" >/dev/null grep -F 'omarchy-hyprland-monitor-external-active' "$monitor_internal" >/dev/null grep -F 'wake' "$monitor_internal" >/dev/null grep -F 'omarchy-hyprland-toggle-enabled $TOGGLE || return 0' "$monitor_internal" >/dev/null