Integrating with the Things app
As part of my never-ending quest to Realize My Potential™, I’ve long been using the Things app (on my iPhone; on macOS) for a variety of things, but especially including keeping track of tasks I need to do. One thing that’s always bugged me, though, is you can’t attach files to Things entries. My hacked together solution, for now, is to keep a folder on a cloud service, and to create UUID-named directories under that folder, and to include a note in the Things entry that includes the UUID so I can easily find the files I need to reference for that task. It’s a kludge, but it’s a workable one.
Things has a basic API. (There are other ways of interfacing with Things, but this is the one I’m currently using / exploring.)
From Terminal, I ran: open "things:///version"
Which caused this to pop up:
Easy so far. I of course enabled it. Next step: Actually add a task to the Inbox. (This is even more of a kludge, it doesn’t properly URL encode the user input, but I’m not likely to include anything more than A-Z, a-z, 0-9, and spaces, so it should work for this limited purpose.)
% open "things:///add?title=`echo -n "This is a test task for Things" | sed s/\ /%20/g;`"
That had the expected result:
So far, so good. Let’s build a script:
% bbedit new_task.command
And, yay, my hacked-together monstrosity works:
The code (it’s not pretty or robust but as a quick hacked together thing it works for what I need):
#!/usr/bin/env bash
export IFS=$'\n'! # handle spaces in $0, e.g.
while [ -e /dev/null ]
do
clear
echo -n "New task (ctrl-c to exit): "
read TASK
UUID="`/usr/bin/uuidgen | tr '[:upper:]' '[:lower:]'`"
DIRECTORY="`dirname "$0"`"
TASKDIR="`date '+%Y.%m.%d'` $TASK $UUID"
mkdir "$DIRECTORY/$TASKDIR"
URLTD="`echo -n $TASKDIR | sed s/\ /%20/g;`"
TITLE="`echo -n $TASK | sed s/\ /%20/g;`"
open "things:///add?title=$TITLE¬es=$URLTD"
done
And now I can, e.g., drag-and-drop the wiring diagram I need into the appropriate folder, and when I (eventually) get around to replacing the pickups on the EC-256, I can find that diagram (even if it’s been removed from the web for some reason).
Huzzah.



Comments
Post a Comment