/ de-omarchy / bin / omarchy-hyprland-session-locked
swadhinbiswas Initial de-omarchy: Omarchy UI layer for Arch-based distros · 8/22/2026
9f393b2
30 lines · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash

# omarchy:summary=Returns true when the compositor holds a session lock
# omarchy:hidden=true

# Hyprland reports no lock state directly, but an active ext-session-lock is one
# of the reasons a monitor cannot go solitary: LOCK in solitaryBlockedBy. It
# stays set once the lock's client dies, which is the case worth detecting.
#
# Exits 0 locked, 1 unlocked, 2 undetermined. Hyprland stops at the first reason
# on a monitor with no workspace yet, before it ever reaches the lock, so a
# missing LOCK there means nothing was asked. Callers branching only on success
# treat 2 as unlocked.
monitors=$(hyprctl -j monitors 2>/dev/null) || exit 2

state=$(jq '
  def blockers: .solitaryBlockedBy // [];
  def readable: blockers | index("WORKSPACE") | not;

  if   any(.[]; blockers | index("LOCK")) then 0
  elif any(.[]; readable)                 then 1
  else                                         2
  end
' <<<"$monitors" 2>/dev/null)

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