Skip to content

Instantly share code, notes, and snippets.

@mribica
Last active January 19, 2018 10:07
Show Gist options
  • Save mribica/23fc367d670e7131751d to your computer and use it in GitHub Desktop.
Save mribica/23fc367d670e7131751d to your computer and use it in GitHub Desktop.
intrusion detection
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