#!/bin/bash

# blob:summary=Lock and reconcile displays when the laptop lid closes
# blob:group=system
# blob: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.
# blob-system-sleep 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 blob-hw-laptop-closed && ! blob-hw-external; then
  blob-system-lock >/dev/null 2>&1 || true
fi

blob-hypr-monitor-clamshell
