Last active
January 19, 2018 10:07
-
-
Save mribica/23fc367d670e7131751d to your computer and use it in GitHub Desktop.
intrusion detection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Starting Intruder" | |
sleep 3 | |
while true do | |
result = `ioreg -r -k AppleClamshellState -d 4 | grep AppleClamshellState | head -1` | |
lid_closed = result.split("=")[1].strip | |
puts "Closed #{lid_closed}" | |
if lid_closed == "No" | |
sleep 2 | |
exec "say alert;imagesnap ~/Pictures/intruder.jpeg;open ~/Pictures/intruder.jpeg" | |
exit | |
end | |
sleep 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment