Skip to content

Instantly share code, notes, and snippets.

@chrismdp
Last active June 18, 2016 18:50
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chrismdp/5017659 to your computer and use it in GitHub Desktop.
Save chrismdp/5017659 to your computer and use it in GitHub Desktop.
Shell script to grab latest tasks from Wunderlist 2. The path for the DB file is the App Store version. Note that as well as passing the list you want (or "" for all tasks) you can pass a relative time as a second argument: eg "+7d" which will limit the view to only tasks due within that time. ("+7d" limits tasks shown to those due within the ne…
#!/bin/sh
set -e
LIST=$1;
DUE=$2;
WUNDERLISTDB="$HOME/Library/Containers/com.wunderkinder.wunderlistdesktop/Data/Library/Application Support/Wunderlist/WKModel.sqlite"
if [ "$LIST" == 'Inbox' ]; then
LID="AND ZTASKLIST is null";
elif [ -z "$LIST" ]; then
LID=""
else
LID=`sqlite3 -list "$WUNDERLISTDB" "select 'AND ZTASKLIST='||Z_PK from ZRESOURCE R, Z_PRIMARYKEY K where K.Z_NAME='TaskList' and R.Z_ENT=K.Z_ENT and R.ZTITLE='$LIST'"`
fi
if [ -z "$DUE" ]; then
DUE_CLAUSE="";
else
DATE=`date -v $DUE +%s`
DUE_CLAUSE="AND ZDUEDATE <= `expr $DATE - 978307200`";
fi
sqlite3 -list "$WUNDERLISTDB" "select case when ZSTARRED=1 then '* '||ZTITLE||'' else '- '||ZTITLE end from ZRESOURCE R, Z_PRIMARYKEY K where K.Z_NAME='Task' AND R.Z_ENT=K.Z_ENT $DUE_CLAUSE $LID AND ZPARENTTASK is null AND ZDELETEDAT is null AND ZCOMPLETEDAT is null order by ZDUEDATE, ZORDERINDEXDOUBLE asc"
@valkenburg
Copy link

After line 10, I add

elif [ "$LIST" == 'Starred' ]; then
  LID="AND ZSTARRED=1"

in order to be able to fetch the 'starred' smartlist.

@chrismdp
Copy link
Author

chrismdp commented Mar 3, 2014

Had a request for a time zone adjustment on this script. To change the timezone, try tweaking the number on line 21 which adjusts the time period we select tasks from.

Something like:

DUE_CLAUSE="AND ZDUEDATE <= `expr $DATE - 978307200 - 18000`";

Will move the time period 18,000 seconds (or five hours) back from GMT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment