Things3 to Beeminder (ToDoZero)

Inspired by @k1rsty’s Beeminding by k1rsty, I realized that I’d not posted my own inboxzero setup for todos.

On a Mac, using Things3, but this approach should generalize to anything that has an AppleScript interface, such as Apple Mail.

#!/bin/sh

# send the number of items in the Things today list to Beeminder

applescript=$(cat <<END

tell application "Things3"
	set todoCount to 0
	repeat with itemToDo in to dos of list "Today"
		set todoCount to todoCount + 1
	end repeat
	--display dialog todoCount
	return todoCount
end tell

END
)
count=$(echo "$applescript" | /usr/bin/osascript)


MEMORY=/Users/philip/src/bmndr/.thingszero.lastcount
TODAY=/Users/philip/src/bmndr/.today.date

# make a midnight comparison file
/usr/bin/touch -t $(/bin/date +%m%d)0000 "$TODAY"

if [ "$MEMORY" -nt "$TODAY" ] ; then
  # exists and is from today - check value
  lastcount=$(cat "$MEMORY")
  if [ $count -eq $lastcount ] ; then
    # no update required
    exit 0
  fi
fi

/Users/philip/bin/bmndr thingszero $count && echo $count > "$MEMORY"


You’ll have to adjust that to fit your own directory structure and whatever command line thing you use to send datapoints to Beeminder.

And then to run it every few minutes I added this to ~/Library/LaunchAgents/net.hellyer.thingszero.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>net.hellyer.thingszero</string>
    <key>Program</key>
    <string>/Users/philip/src/bmndr/thingszero.sh</string>
    <key>StartInterval</key>
    <integer>327</integer>
    <key>RunAtLoad</key>
      <true/>
  </dict>
</plist>

Because it runs every few minutes, if I set the graph to plot all datapoints, I get a sense of how things progressed over the day. That’s a custom setting, so you’d have to change the goal type to custom, which in turn requires a premium plan.

2 Likes

Very nice.
Alternative idea: under the hood Things3 uses SQLite database.

1 Like