Advertisement
Guest User

-- SecuritySpy "hot screen" script v1.0 (modified .1)

a guest
Nov 3rd, 2014
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- SecuritySpy "hot screen" script v1.0 (modified .1)
  2. -- 2014/11/01 John Todd jtodd@loligo.com
  3. -- modfied 2014/11/03 ncowles@me.com
  4. --
  5. -- Load this script into AppleScript Editor, and save as an scpt file to:
  6. -- ~/Documents/SecuritySpy/Scripts
  7. --
  8. -- Then for all your cameras in SecuritySpy, attach this
  9. -- script as an "action".
  10. --
  11. -- I leave my SSpy machine in "full grid" mode when it is idle,
  12. -- so I can see a quick view of all the cameras. However, when
  13. -- there is motion detected, I'd like to see just those cameras that
  14. -- are having motion events. This focuses in on the cameras that
  15. -- are in "motion detect" mode, and shows them in full screen. When
  16. -- the events are completed, it goes back to full grid.
  17. --
  18. -- Improvements welcome.
  19.  
  20. on run arg
  21.     set idleTime to (do shell script "ioreg -c IOHIDSystem | perl -ane 'if (/Idle/) {$idle=(pop @F)/1000000000; print $idle,\"\";last}'") as integer
  22.    
  23.     if idleTime > 30 then
  24.         do shell script "~/Documents/SecuritySpy/SleepDisplay -w" -- WAKE DISPLAY ASAP
  25.        
  26.         tell application "SecuritySpy"
  27.             activate
  28.         end tell
  29.     end if
  30.    
  31.     set camNumber to item 1 of arg
  32.     set totalCams to 5 -- set this to the number of cameras in your system
  33.     set activeCams to totalCams - 1
  34.     set currentCam to 1
  35.     set recording to ""
  36.    
  37.     set camNameToSay to item 2 of arg -- PLACE CAMERA NAME FROM SECURITYSPY INTO VARIABLE
  38.    
  39.    
  40.     tell application "SecuritySpy"
  41.         enter full screen mode
  42.         add full screen camera number camNumber -- immediately show MD camera (no test needed)
  43.     end tell
  44.    
  45.    
  46.     tell application "System Events" -- SAY NAME OF TRIGGERED CAMERA ASAP
  47.         tell process "Finder"
  48.             say camNameToSay
  49.         end tell
  50.     end tell
  51.    
  52.     tell application "SecuritySpy"
  53.        
  54.         repeat while activeCams > 0 -- as long as there are any cams doing MD, loop
  55.            
  56.             set activeCams to totalCams - 1
  57.             repeat until currentCam > totalCams -- loop on all cameras
  58.                
  59.                
  60.                 -- if we try to look at a motion detection file for a camera
  61.                 -- that isn't recording an MD file, it throws an error. Trap
  62.                 -- the error and use that error to indicate that this camera should
  63.                 -- not be shown on the "hot screen".
  64.                 try
  65.                     set recording_test to (get current MD file camera number currentCam)
  66.                 on error errMsg number errorNumber
  67.                     remove full screen camera number currentCam
  68.                     set activeCams to (activeCams - 1)
  69.                     set recording_test to null
  70.                 end try
  71.                
  72.                
  73.                 -- if there is currently an MD file being recorded, then
  74.                 -- we want to see it on the hot screen.
  75.                 if (recording_test is not equal to null) then
  76.                     add full screen camera number currentCam
  77.                     set activeCams to (activeCams + 1)
  78.                 end if
  79.                
  80.                 set currentCam to (currentCam + 1) -- increment counter for loop
  81.                
  82.             end repeat
  83.             set currentCam to 1 --aaaand wash, rinse, repeat.
  84.            
  85.             delay 1 -- pause for a bit to give the machine a break
  86.         end repeat
  87.        
  88.        
  89.         -- Now that we're out of the motion detection events,
  90.         -- set the screen back to showing all cameras in a grid, and exit.
  91.        
  92.         set currentCam to 1
  93.         repeat while currentCam ≤ totalCams
  94.             add full screen camera number currentCam
  95.             set currentCam to currentCam + 1
  96.         end repeat
  97.        
  98.     end tell
  99.    
  100. end run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement