#!/bin/bash

# omarchy:summary=Lock and reconcile displays when the laptop lid closes
# omarchy:group=system
# omarchy:hidden=true

# Locking here rather than waiting for PrepareForSleep is what keeps the lock
# off the critical path. logind's delay inhibitor is a timer that expires
# whether or not the session is secure, so starting the lock the moment the lid
# closes gives Quickshell a head start before logind even decides to suspend.
# omarchy-system-sleep-lock then usually finds the session already secure.
#
# A docked lid close does not suspend (HandleLidSwitchDocked defaults to
# ignore), so it must not lock either: that is clamshell mode, still in use on
# the external display.
if omarchy-hw-laptop-closed && ! omarchy-hw-external-monitors; then
  omarchy-system-lock >/dev/null 2>&1 || true
fi

omarchy-hyprland-monitor-clamshell
