/ de-omarchy / bin / omarchy-hyprland-monitor-modeless
swadhinbiswas Initial de-omarchy: Omarchy UI layer for Arch-based distros · 8/22/2026
9f393b2
22 lines · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash

# omarchy:summary=Returns true when Hyprland has an enabled monitor with no mode
# omarchy:hidden=true

# A monitor powered off at boot answers with a partial EDID carrying no video
# modes, so Hyprland brings it up at 0x0 and the screen stays black. Mirrors are
# absent from plain `monitors`, hence `all` plus an explicit disabled filter.
#
# Exits 0 modeless, 1 not, 2 when the compositor cannot say. Nothing fires an
# event for this state, so a caller that gave up on an unanswered query would
# leave the screen black for good.
monitors=$(hyprctl monitors all -j 2>/dev/null) || exit 2

state=$(jq 'if any(.[]; .disabled != true and (.width == 0 or .height == 0)) then 0 else 1 end' \
  <<<"$monitors" 2>/dev/null)

case $state in
  0 | 1) exit "$state" ;;
  *) exit 2 ;;
esac