#!/bin/bash

# omarchy:summary=Reopen the Secure Boot setup at the login after a reboot it asked for
# omarchy:hidden=true

# omarchy-setup-security-secure-boot queues this with omarchy-provision-next-boot
# before each reboot it asks for, so the next step opens by itself, and says
# how the boot loader switch went: that is the only place the switch reports.
# A machine on Limine with no trial behind it never took the switch (declined,
# or reverted), and has no step to continue.
#
# The terminal is left running in the background: the queue waits for this to
# return, and takes a failure as a reason to run it again at the next login.

phase=$(sed -n 's/^phase=//p' /var/lib/omarchy/boot/state 2>/dev/null | tail -1)

if [[ $(omarchy-boot-backend) == "systemd-boot" || $phase == trial* ]]; then
  omarchy-launch-floating-terminal-with-presentation omarchy-setup-security-secure-boot &>/dev/null &
fi
