Last active
June 18, 2016 18:50
-
-
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…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
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
After line 10, I add
in order to be able to fetch the 'starred' smartlist.