objective-see / objective-see/DoNotDisturb
Sample script to snap a webcam image, then send an email alert with the image
Nobody has claimed this yet.
- Dominant language
- Objective-C
- Stars
- 330
- Forks
- 49
- PR merge metrics
- No merged PRs in 30d
Description
This (snapperwmailf.app) is an applescript based app which snaps an image (in this case when the lid of the laptop is opened) and then sends an email alert along with the image. I'm not really a programmer (but have some background), so it took me a while to figure this out. But I hope it helps some other people...
set formattedDate to (do shell script "date +'%m%d%y-%H%M%S'")
set fullPath to "/Users/username/Desktop/ImageSnap/images/" & formattedDate & ".jpg"
set theScript to "/usr/local/bin/imagesnap -w 5 /Users/username/Desktop/ImageSnap/images/" & formattedDate & ".jpg"
do shell script (theScript)
delay 1
set recipientName to "John"
set recipientAddress to "john@doe.com"
set theSubject to "Alert on my Mac!"
set theContent to "Something is going on, maybe you want to check it"
tell application "Mail"
set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
tell theMessage
make new to recipient with properties {name:recipientName, address:recipientAddress}
make new attachment with properties {file name:fullPath}
delay 1
end tell
send theMessage
end tell
This script uses: http://iharder.sourceforge.net/current/macosx/imagesnap/
You can find installation instructions and sample usage here:
https://eyetea33.wordpress.com/2013/06/11/take-pictures-using-facetime-hd-or-isight-camera-on-mac-wakeup/
You should export the script as an app (using script editor), and then take some steps to make sure the system doesn't ask you for permission to use the camera and mail app each time. Read the comments of JayBrown how to achieve this here https://github.com/rharder/imagesnap/issues/26. But basically,
"Open the Info.plist (visible when you say show package contents of the app), add key LSUIElement with boolean true, change the BundleID, if you want, change the bundle icon"
Then You should also create a self-signed certificate, and then sign the app with the certificate.
- creating the certificate: https://developer.apple.com/library/archive/documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html [under To obtain a self-signed certificate using Certificate Assistant]
also https://eclecticlight.co/2019/01/16/code-signing-for-the-concerned-2-creating-a-personal-certificate/ - signign the certificate with terminal (when you're in the folder of the app): codesign --sign "OKs certifcate" --force --deep -i "com.apple.ScriptEditor.id.snapperwmailf" snapperwmailf.app
- while signing the certificate I encountered an error and found the fix here: https://stackoverflow.com/questions/39652867/code-sign-error-in-macos-high-sierra-xcode-resource-fork-finder-information
The system will ask the permission to use the camera and mail for the first time. But if you did the signing right it shouldn't ask again. Then on DND's preferences, you say execute action and provide: open ~/Desktop/ImageSnap/snapperwmailf.app
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the AppleScript block and the referenced snapperwmailf.app and Info.plist instructions; review the repository's existing documentation or example structure before deciding where this belongs. Verify the documented imagesnap, signing, and Do Not Disturb action flow on macOS. Done means the sample and setup steps are incorporated in the expected project location and can be followed reproducibly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- shell
- Domain
- operating-systems, security
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100