Skip to content

Instantly share code, notes, and snippets.

@JoeOIVOV
Forked from aphexddb/.wakeup
Created May 14, 2023 05:10
Show Gist options
  • Save JoeOIVOV/e7040f6db043e0fac2c1d3577623a9bc to your computer and use it in GitHub Desktop.
Save JoeOIVOV/e7040f6db043e0fac2c1d3577623a9bc to your computer and use it in GitHub Desktop.
OSX sleepwatcher script to take a photo on wakeup and upload to dropbox
#!/bin/bash
#
# Mac camera auto upload script
#
#####################################################
# Generate filename based on date stamp
FILE_SRC=/tmp/$(date +%m%d%y%H%M%S).jpg;
DROPBOX_FOLDER=macbook
DROPBOX_UPLOADER=/Users/<username>/Dropbox-Uploader/dropbox_uploader.sh
# Take iSight Photo and store in /tmp with datestamp filename
/usr/local/bin/imagesnap -q $FILE_SRC;
# Wait a little while, if Mac is waking from sleep, needs a moment to connect to network
sleep 60;
# Generate semaphore for connectivity by pinging NASA
isconnected=$(ping -c 1 www.nasa.gov | grep 64 | wc | awk '{print $1}');
# If connected...
if [ "$isconnected" -eq "1" ]; then
for f in /tmp/*jpg;
do
$DROPBOX_UPLOADER upload $f $DROPBOX_FOLDER;
rm $f;
done
else
# If not connected.. leave captures there until next time.
echo "No Connection, Image not transferred or deleted.";
fi

OSX sleepwatcher script to take a photo on wakeup and upload to dropbox

  1. install Dropbox-Uploader

  2. install imagesnap

     $ brew install imagesnap
    
  3. install sleepwatcher

     $ brew install sleepwatcher
    
  4. Drop the .wakeup file in your home dir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment