Move to a hardware check for external monitors instead to deal with recover timing

This commit is contained in:
David Heinemeier Hansson
2026-04-23 11:14:14 +02:00
parent 6953ea9af8
commit 96afc68461
4 changed files with 12 additions and 12 deletions
+10
View File
@@ -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
+2 -2
View File
@@ -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
}
-5
View File
@@ -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 ))
-5
View File
@@ -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 ))