# Logging your Mood with Alfred

Since early December 2018 I’ve tracked my mood and energy while working at the computer. This has been quite interesting in terms of self-reflection and adjusting both my work and personal habits. Maybe I’ll share some insights in the future.

Meanwhile, if you’re interested in doing the same, here’s the hacky way I do it. This is macOS specific, so I can’t speak to using Windows or Linux to do the same, but I suspect it would be similar enough that you can figure it out if you really want to do it.

## Requirements

1. Alfred, a phenomenal free app to increase your productivity. Like Spotlight on steroids, really great. If you can, get the PowerPack license for even more awesome features.
2. A text editor. Any one will do, I use SublimeText but you can use TextEdit, VSCode or Vim or whatever else floats your boat.
3. Passing familiarity with the Terminal.

## Setup

1. Install Alfred
2. Create a file called large-type.scpt with your text editor somewhere on your computer. I have mine in ~/coding/scripts/.
3. Copy the following text into the file and save it:
on run argv
tell application "Alfred 3"
search item 1 of argv
tell application "System Events"
keystroke "l" using {command down, option down}
end tell
end tell
end run
1. Create a new file called reminder.sh. I’ve put mine into ~/coding/scripts/ as well.
2. Copy the following code into it and save:
#!/bin/bash
osascript {path/to/your}/large-type.scpt "$@" Make sure to substitue {path/to/your} with the correct full path to the file. You can get the full path very easily by right-clicking on large-type.scpt and then pressing alt/option. You’ll see an option “Copy large-type.scpt as Pathname”, which you can click. 1. Create a new file called my_crontab (no extension!) somewhere on your computer with your text editor. You know where I’ve put mine ;) 2. Copy the following code into the file and save it: 30 4-21/* * * * sleep${RANDOM:0:2}m ; {path/to/your}/reminder.sh "Track Mood"

Again, make sure to substitute {path/to/your}

1. Open Terminal and run the following command
crontab {path/to/your}/my_crontab

## Explanation

Okay, what exactly is happening here?
If everything is working correctly, you will be prompted regularly with the text “Track Mood” in very large letters. This happens through Alfred’s “Large Type” feature.
It should look like this:

When you are prompted is determined in your my_crontab file. I’ve used Ole Michelsen’s advice on how to set up crontabs, he explains nicely how crontabs work.

In this case:

30 4-21/* * * *  carry out our command
│    │    │ │ │
│    │    │ │ └─── day of week (0 - 6) (on every wekday)
│    │    │ └──────── month (1 - 12) (in every month of the year)
│    │    └───────────── day of month (1 - 31) (on every day of the month)
│    └────────────────── hour (0 - 23) (between 4am and 9pm)
└─────────────────────── min (0 - 59) (everytime it's xx:30)

The command we are running does the following:

sleep ${RANDOM:0:2}m ; {path/to/your}/reminder.sh "Track Mood" 1. First, it waits some random duration, so that we’re not always tracking our mood at the exact same time. Check this StackOverflow answer to see how this works. 2. Once the waiting is over, it prompts you with the message “Track Mood” in large type You can easily prompt yourself to track other things by changing “Track Mood” and/or duplicating the line and adding another message: 30 4-21/* * * * sleep${RANDOM:0:2}m ; /Users/lukas/coding/scripts/reminder.sh "Track Mood"
30 4-21/* * * * sleep \${RANDOM:0:2}m ; /Users/lukas/coding/scripts/reminder.sh "Track Energy"