Starshun

The occasional ravings of James Kellerman

Script to add a selfie every day to Day One

I was looking over an old backup when I came across a series of photos that I had taken as part of a picture a day project. Looking back on the photos was interesting; the different places, clothes and hairstyles that are the boring minutae of most days are rendered fascinating by their setting in a sequence. These were all ungaurded moments that reminded moI liked the photos but I wanted a better place to put them. Day One seemed like the perfect answer I was alredy using it for journaling and it supports a great command line interface.

What does it do? Snaps a photo at startup from your macbookpro camera and at 9:30 every morning. It then saves that image to a folder using the date for the filename and posts it to your day one journal.

What does it need to work

ImageSnap A comman line utility for taking pictures with the built-in isight camera. The easiest way to install this is via homebrew: brew install imagesnap

Day One A fantastic journaling application

Day One Command Line Tools Command line tools for Day One

Once you have all these installed you can use the following simple script to link it all together.

#!/bin/bash    


# The file name here we are using the date in Y-M-D format
FILE=$(date +"%Y-%m-%d").jpg

# the image path to save the image
IMAGEPATH=/Users/jkellerman/Dropbox/Images/me/


FILEPATH="$IMAGEPATH$FILE"


# Snap the photo
/usr/local/bin/imagesnap "$FILEPATH"

# Add the iamge to dayone
echo "Daily Image" | /usr/local/bin/dayone -j="path to dayone journal" -p="$FILEPATH" new

# Sleep to stop lauchd thinking we are just dying
sleep 10s

The last thing you need is a launctl plist file that tells the script when to run. Here is the one I am using to run the script every day at 9:30am. This lives in /Library/LaunchDaemons/

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN
http://www.apple.com/DTDs/PropertyList-1.0.dtd >
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.example.exampled</string>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>/Users/jkellerman/scripts/isighttodayone.sh</string>
</array>

<key>KeepAlive</key>
<false/>

<key>RunAtLoad</key>
<true/>

<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>9</integer>
<key>Minute</key>
<integer>30</integer>
</dict>


</dict>
</plist>



New job, new posts?

I have a new job! Which in many ways is not that big a deal but it is a good excuse to start writing again. I am now engineering director at Thetus Corporation. It's is a big change and I am excited to get my teeth into the problems of model driven analytics. My new office is conveniently located right across the street from my old office. Importantly it's still a 10 minute walk to the office in the morning, just long enough to wake up and get through a podcast every couple of days.

I will be writing more, in fact beeminder.com is going to help keep me to it.