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:
Then install sleepwatcher
:
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 imagesnap
.
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
Copy de.bernhard-baehr.sleepwatcher-20compatibility-localuser.plist
file into /Library/LaunchDaemons/
:
and edit it:
With -w
option, /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:
then sleepwatcher
starts to monitor the sleep/wake state of your machine.
Now your selfie will be captured on every wake up!