Take a selfie on every wake-up from sleep (macOS)
For some reason, I wanted to take a selfie whenever my Macbook Air wakes up from sleep.
Here are the steps I took for it:
0. Install tools that are needed
imagesnap is a command line tool which takes a photo with the built-in camera of Macbook.
Install it with brew:
It will be used for monitoring sleep/awake states of the Macbook.
1. Create a shell script
Create a script that will save photos using
This script will save captured images into the SAVE_PATH.
Saved images will be named like captured_20160331_2058.jpg.
Now it’s time to set
sleepwatcher up, which will execute this script.
2. Setup sleepwatcher
de.bernhard-baehr.sleepwatcher-20compatibility-localuser.plist file into
and edit it:
/path/to/script.sh will be executed on wake. (if you need, use
-s for sleep state)
You can see more options by running
/usr/local/sbin/sleepwatcher without any option.
Now load this file:
sleepwatcher starts to monitor the sleep/wake state of your machine.
Now your selfie will be captured on every wake up!