Skip to content

Instantly share code, notes, and snippets.

@agmm
Created October 17, 2021 19:56
Show Gist options
  • Save agmm/1c4aeaef29717c9537ecc7d50ab63e03 to your computer and use it in GitHub Desktop.
Save agmm/1c4aeaef29717c9537ecc7d50ab63e03 to your computer and use it in GitHub Desktop.
lock-screen-state
function screenIsLocked { [ "$(/usr/libexec/PlistBuddy -c "print :IOConsoleUsers:0:CGSSessionScreenIsLocked" /dev/stdin 2>/dev/null <<< "$(ioreg -n Root -d1 -a)")" = "true" ] && return 0 || return 1; }
function screenIsUnlocked { [ "$(/usr/libexec/PlistBuddy -c "print :IOConsoleUsers:0:CGSSessionScreenIsLocked" /dev/stdin 2>/dev/null <<< "$(ioreg -n Root -d1 -a)")" != "true" ] && return 0 || return 1; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment