I'm developing a background agent program for macOS that locks users out of their session and forces them to re-authenticate if certain security conditions are violated.
Previously, I used 'CGSession -suspend' to do this, but it no longer works in Big Sur. One recommendation I've seen is to create a macro that uses the default keyboard shortcut (ie 'CTRL+CMD+Q'), however this obviously won't work if the user has configured their shortcuts differently; the same goes for other methods that require certain user preferences to be set (eg run 'pmset displaysleepnow' after setting preferences to require password immediately after sleep or screensaver). I'm looking for something that's more authoritative/dependable than that, eg an API of some sort. Does such a thing exist?