For years, I've used Applescripts to check if my Mac's monitor is locked (not to be confused with checking if the screen saver is active. I don't have the screen saver lock the screen since I use the screen saver as a giant clock when I'm home and I lock the screen when I leave).
Either the switch to Apple silicon or a Mac OS update has stopped scripts like this from checking if the screen is locked:
set isScreenLocked to do shell script "pmset -g ps | awk 'NR==2{print $2}'"
Scripts like this don't seem to work on Apple silicon either:
set isScreenLocked to do shell script "ioreg -n IODisplayWrangler | grep -i IOPowerManagement"
I'm running Mac OS Sonoma on an M1 Mac studio. How can I use Applescript to check whether or not the screen is locked (again, not to be confused with the screen saver being active)?
pmset -g ps
to be, when locked? Theman
page says that displays the battery status. (Also, I'm curious: what does the script do when the screen is locked?)