Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- SecuritySpy "hot screen" script v1.0 (modified .1)
- -- 2014/11/01 John Todd jtodd@loligo.com
- -- modfied 2014/11/03 ncowles@me.com
- --
- -- Load this script into AppleScript Editor, and save as an scpt file to:
- -- ~/Documents/SecuritySpy/Scripts
- --
- -- Then for all your cameras in SecuritySpy, attach this
- -- script as an "action".
- --
- -- I leave my SSpy machine in "full grid" mode when it is idle,
- -- so I can see a quick view of all the cameras. However, when
- -- there is motion detected, I'd like to see just those cameras that
- -- are having motion events. This focuses in on the cameras that
- -- are in "motion detect" mode, and shows them in full screen. When
- -- the events are completed, it goes back to full grid.
- --
- -- Improvements welcome.
- on run arg
- set idleTime to (do shell script "ioreg -c IOHIDSystem | perl -ane 'if (/Idle/) {$idle=(pop @F)/1000000000; print $idle,\"\";last}'") as integer
- if idleTime > 30 then
- do shell script "~/Documents/SecuritySpy/SleepDisplay -w" -- WAKE DISPLAY ASAP
- tell application "SecuritySpy"
- activate
- end tell
- end if
- set camNumber to item 1 of arg
- set totalCams to 5 -- set this to the number of cameras in your system
- set activeCams to totalCams - 1
- set currentCam to 1
- set recording to ""
- set camNameToSay to item 2 of arg -- PLACE CAMERA NAME FROM SECURITYSPY INTO VARIABLE
- tell application "SecuritySpy"
- enter full screen mode
- add full screen camera number camNumber -- immediately show MD camera (no test needed)
- end tell
- tell application "System Events" -- SAY NAME OF TRIGGERED CAMERA ASAP
- tell process "Finder"
- say camNameToSay
- end tell
- end tell
- tell application "SecuritySpy"
- repeat while activeCams > 0 -- as long as there are any cams doing MD, loop
- set activeCams to totalCams - 1
- repeat until currentCam > totalCams -- loop on all cameras
- -- if we try to look at a motion detection file for a camera
- -- that isn't recording an MD file, it throws an error. Trap
- -- the error and use that error to indicate that this camera should
- -- not be shown on the "hot screen".
- try
- set recording_test to (get current MD file camera number currentCam)
- on error errMsg number errorNumber
- remove full screen camera number currentCam
- set activeCams to (activeCams - 1)
- set recording_test to null
- end try
- -- if there is currently an MD file being recorded, then
- -- we want to see it on the hot screen.
- if (recording_test is not equal to null) then
- add full screen camera number currentCam
- set activeCams to (activeCams + 1)
- end if
- set currentCam to (currentCam + 1) -- increment counter for loop
- end repeat
- set currentCam to 1 --aaaand wash, rinse, repeat.
- delay 1 -- pause for a bit to give the machine a break
- end repeat
- -- Now that we're out of the motion detection events,
- -- set the screen back to showing all cameras in a grid, and exit.
- set currentCam to 1
- repeat while currentCam ≤ totalCams
- add full screen camera number currentCam
- set currentCam to currentCam + 1
- end repeat
- end tell
- end run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement