about 
 damon.io
articles
 » « 

How to display Toodledo tasks on your Mac desktop

By Damon Mannion · · ·

My aim was to replace the flock of high-priority post-it notes covering edges of my monitor. Using Geektool and one shell script later, my starred Toodledo tasks are now displayed on my desktop.

Geektool enables items to be placed on the Mac desktop and refreshed at regular intervals. The approach I took was to use Geektool to regularly run a shell script and send its output to the desktop. There are two parts to this: the shell script and the awk script.

todo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
# get the toodledo task list into todo.csv, using curl and the password stored in keychain
pwd=$(security find -ws toodledo)
curl -k -c /tmp/cookies.txt --insecure --data 'email=myemail@mydomain.tld&pass='$pwd https://www.toodledo.com/signin.php
curl -b /tmp/cookies.txt https://www.toodledo.com/tools/csv.php?view=1 > /tmp/todo.csv
rm /tmp/cookies.txt

# loop through awk script to output filtered tasks
cd ~/_sync/todo
for i in {1..4}
do
	/usr/local/bin/gawk -v filter=$i -f toodledo.awk /tmp/todo.csv | sort -f
done
rm /tmp/todo.csv

In the shell script above, I set the Toodledo password in OSX’s Keychain so it’s not embedded in the script. This requires a click on the ‘always allow’ option the first time you run the script, or you can relax the permissions on this element in the Keychain Manager. The first Curl line logs into Toodledo and stores the cookie, the second one uses the cookie to authenticate and the URL used is the one to export tasks as a csv.

toodledo.awk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# splits a toodledo csv file, expects the 'filter' param to be set which determines which rows to print

# csv.awk is from here: http://lorance.freeshell.org/csv/
@include "csv.awk"

# print spacer line every time, except first time
BEGIN{
	if (filter!=1)
		print
}

# split the csv file correctly, which rows to print depends on the filter flag
{
	parse_csv($0, csv, ",", "\"", "\"", "\\n", 1)
	if	(	( filter==1 && csv[1]=="Damon" && csv[15]=="Yes") \
		||	( filter==2 && csv[1]!="Damon" && csv[15]=="Yes") \
		||	( filter==3 && csv[1]=="Damon" && csv[15]!="Yes") \
		||	( filter==4 && csv[1]=="focus" && csv[15]!="Yes") \
		)
		print csv[1] " - " csv[0]
}

The Awk script, which is dependent on the parse_csv library, is then used to filter the tasks. As I wanted to display multiple sets of tasks in different groups, a filter id is passed in from the shell script to the Awk one – this keeps it as DRY as my limited Bash and Awk skills allow!

The filters are as follows:

  1. anything starred in the Damon folder
  2. anything starred but not in the Damon folder
  3. anything in the Damon folder but not starred
  4. anything in the focus folder but not starred

The Toodledo columns in the csv file are ordered as below, and it’s easy to add additional items, filters, etc.:

  1. task
  2. folder
  3. context
  4. goal
  5. location
  6. start date
  7. start time
  8. due date
  9. due time
  1. repeat
  2. length
  3. timer
  4. priority
  5. tag
  6. status
  7. star
  8. note

It’s all reasonably straightforward stuff, but has removed the post-it note butterfly farm from my screen, and means that my critical item reminders are now ‘in my face’ across all my devices, not just when I’m sat at my desk.