From 96afc684611a847a1a4a9c179f80441fc3652baf Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 23 Apr 2026 11:14:14 +0200 Subject: [PATCH] Move to a hardware check for external monitors instead to deal with recover timing --- bin/omarchy-hw-external-monitors | 10 ++++++++++ bin/omarchy-hyprland-monitor-internal | 4 ++-- bin/omarchy-hyprland-monitors-many | 5 ----- bin/omarchy-hyprland-monitors-none | 5 ----- 4 files changed, 12 insertions(+), 12 deletions(-) create mode 100755 bin/omarchy-hw-external-monitors delete mode 100755 bin/omarchy-hyprland-monitors-many delete mode 100755 bin/omarchy-hyprland-monitors-none diff --git a/bin/omarchy-hw-external-monitors b/bin/omarchy-hw-external-monitors new file mode 100755 index 00000000..b5dc967b --- /dev/null +++ b/bin/omarchy-hw-external-monitors @@ -0,0 +1,10 @@ +#!/bin/bash + +# Returns true when an external monitor is physically connected. +# Uses kernel DRM state so the result is independent of Hyprland's startup timing. + +for status in /sys/class/drm/card*-*/status; do + [[ "$status" == *-eDP-*/status ]] && continue + [[ "$(<"$status")" == "connected" ]] && exit 0 +done +exit 1 diff --git a/bin/omarchy-hyprland-monitor-internal b/bin/omarchy-hyprland-monitor-internal index d30fd34c..6936d2cf 100755 --- a/bin/omarchy-hyprland-monitor-internal +++ b/bin/omarchy-hyprland-monitor-internal @@ -9,7 +9,7 @@ enable() { } disable() { - if omarchy-hyprland-monitors-many; then + if omarchy-hw-external-monitors; then if omarchy-hyprland-toggle-disabled "$TOGGLE"; then omarchy-hyprland-toggle --enabled-notification "󰍹 Laptop display disabled" "$TOGGLE" fi @@ -20,7 +20,7 @@ disable() { } recover() { - if omarchy-hyprland-monitors-none && omarchy-hyprland-toggle-enabled "$TOGGLE"; then + if ! omarchy-hw-external-monitors && omarchy-hyprland-toggle-enabled "$TOGGLE"; then omarchy-hyprland-toggle "$TOGGLE" fi } diff --git a/bin/omarchy-hyprland-monitors-many b/bin/omarchy-hyprland-monitors-many deleted file mode 100755 index 50035c3f..00000000 --- a/bin/omarchy-hyprland-monitors-many +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -# Returns true when there are multiple monitors connected (so we can disable the internal one) - -(( $(hyprctl monitors -j 2>/dev/null | jq length) > 1 )) diff --git a/bin/omarchy-hyprland-monitors-none b/bin/omarchy-hyprland-monitors-none deleted file mode 100755 index 231a0ba7..00000000 --- a/bin/omarchy-hyprland-monitors-none +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -# Returns true when no real monitors are connected (ignoring Hyprland's HEADLESS fallback) - -(( $(hyprctl monitors -j 2>/dev/null | jq '[.[] | select(.name | startswith("HEADLESS") | not)] | length') == 0 ))