The Teardown
Friday :: May 17th, 2024
👋 Hi, this is Chris with another issue of The Teardown. In every issue, I cover how we evolve in concert with the technology that enables our day-to-day lives. If you’d like to get emails like this in your inbox every week, hit the subscribe button below.
I’m Quadrupled Booked!
Life is full of lightbulb moments. You’re thinking about something, or struggling with a task, and you’re suddenly snap-oriented with an answer. Writers block is no longer as letters fly out of your fingers. The art of assembling furniture, or worse, a kids toy, resolves to completion as the pieces snap together after a step back, deep breath, and perhaps a brief argument distraction.A moment of clarity powers you forward.
I’ve experienced a few of these moments recently.
But one problem irked me with almost no end in sight: sorting through a busy calendar.
The matrix of days and weeks was a jumbled mess of my appointments, activities for my daughters, commitments from or for my wife, and other tidbits like automated and never-ending kid-birthday reminders. And, every appointment was the same color. Worst of all, some appointments sat on top of others even if they weren’t actual conflicts for me. I spent too much time just trying to see and make sure I knew about everything.
So, I dug through a familiar past toolbox: code
Introducing The Solution Concept
Many of you use Gmail like me. You might also use Google Calendar given the close link between the two products. Of course, some of you run your lives from your corporate accounts. I don’t, for the moment, and needed an alternative to what was a busy Outlook calendar not long ago.
Gmail is a member of a family of products called Google Workspace, and with it, users get access to a scripting engine that allows for all sorts of creative tinkering. What is the script you use within the engine? From WikiPedia:
In computing, a script is a relatively short and simple set of instructions that typically automate an otherwise manual process. The act of writing a script is called scripting. Scripting language or script language describes a programming language that it is used for a script.[1]
Scripts are usually interpreted rather than compiled.
Notable environments that are scriptable, can be automated via script, include application software, text editor, web page, operating system, embedded system, and computer game.
The notable phrase is that the script helps you automate an otherwise manual process.
What was that for me? Color coding. I long ago start color coding my calendar to unlock a very quick visual understanding of my day. Was it busy with work? If yes, I’d see lots of blue blobs. If I instead blocked time for deep-work, deep-thinking, or my sometimes favorite, deep-nothing, there would be vast swaths of purple on the screen. Kid stuff was green.
I didn’t see an obvious setting in either Calendar or Gmail to color code appointments based on my specific criteria. Instead, I was forced to open each block, edit the color, and save the change.
The process was not overwhelming, but very slow. Also, many events happen on a recurring basis and can be configured with a color from the start. The example image below shows an appointment I created to illustrate the point.
I couldn’t achieve that level of color precision with calendar appointments that I didn’t create. We all get these appointments, all the time. My calendar looked a lot more like this stylized image from an digital desktop fifteen years in the past:
Doesn’t that look miserable? It would still give me anxiety even if every calendar appointment said something like “You win $1M dollars!”
After some research in various nooks and crannies of the internet, I created my Apps Script Project colorizeCalendarEvents.
Designing In Code
I won’t share all of the code here because I don’t think Substack is the right spot for that. I may instead toss it on Github at some point. Or, form an enormously profitable consumer SaaS business selling personal automation hacks.
The design of the solution is straightforward. I run through these steps to pick the color for specific appointments:
Check if the calendar appointment creator is my wife, not me, and track that appointment if true.
Check if the appointment title contains either of the names of my kids, and add another tracking flag to that appointment if so.
Change the color of the appointment to green if that appointment meets the conditions in both (1) and (2).
If instead, the appointment is from my wife and has nothing to do with my kids, color it purple.
The logic for both bullets (3) and (4) above looks something like this in nerd-language:
var qualifiedEvent = CalendarApp.getEventById(event.id);
// Final piece: color purple if wife, green if kid event
if (kidPresence.length > 0) {
console.log(" - Kid Event")
qualifiedEvent.setColor(CalendarApp.EventColor.PALE_GREEN);
}
else {
qualifiedEvent.setColor(CalendarApp.EventColor.MAUVE);
}
The last step involves a trigger mechanism. This happens on the Triggers tab inside the Apps Script interface. In short, when my calendar changes, the underlying engine runs the color function.
There are different ways to approach that trigger problem, but I wanted to catch one specific situation: something landing on my calendar before I’ve manually checked. And, so far, it’s doing the right job. When another person (anyone) sends me a calendar appointment, this process triggers.
Long live deep-nothing.