The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Script: custom OmniFocus action lists on the desktop, using Geektool Thread Tools Search this Thread Display Modes
Ah that's a shame, and there was I hoping it would be something simple :(
 
These scripts are really helpful, but I'm having a problem with the Inbox and Context versions—they both show completed/checked items. I can't figure out how to alter the script show it only shows active or uncompleted items.

I'm a really new OF user, so I don't know if it's a setting that I'm missing. Thank you for any help.
 
Quote:
Originally Posted by RobertK View Post
I can't figure out how to alter the script show it only shows active or uncompleted items.
You can add the condition and dateCompleted is null inside a where clause.

Sth like:
task where inInbox = 1 and dateCompleted is null
or
task join context c on task.context = c.persistentIdentifier where c.name=\"Library\" and dateCompleted is null
--

Last edited by RobTrew; 2012-06-13 at 03:48 AM..
 
Thank you so much!
 
How do I get it to show tasks that are in a certain Single-Action list, project or folder?
 
I haven't built any shortcuts for those – at the moment I'm afraid I'll just have to point you towards post 5 in this thread, and to the documentation for Sqlite3 …

But perhaps others have already shaped up queries for the listings you want ...
 
Here is a template for a shell script (for direct Applescript-free use with Geektool) which uses awk for formatting, and would enable you to list tasks by project.

This version uses the % wildcard to list any projects with names containing the word "write", together with any uncompleted tasks in those projects.

Code:
#!/bin/sh
#OFOC=$(osascript -e 'tell application "Finder" to get id of application file id "OFOC"')
OFOC="com.omnigroup.OmniFocus" # For Appstore-purchased variant use (slower) line above instead
echo "SAMPLE LISTING:"
sqlite3 $HOME/Library/Caches/$OFOC/OmniFocusDatabase2 '
SELECT p.name, c.name, tt.name 
FROM ((task t left join projectinfo pi on t.containingprojectinfo=pi.pk) tt 
left join task p on tt.task=p.persistentIdentifier) 
left join context c on tt.context = c.persistentIdentifier
WHERE tt.dateCompleted is null and p.name like "%write%"
ORDER BY p.name, c.name' | awk '
BEGIN {FS="\|"; prj=0; ctx=0;}
{
	# Whenever the value of col. 1 changes, 
	# write it out as a PROJECT header,
	if (prj!=$1) {prj=$1; if (length(prj) < 1) {print "\n(INBOX)"} 
	else {print "\n" toupper(prj)}};
	
	# and whenever the value of col. 2 changes, 
	# write it out as a [CONTEXT] sub-header.
	if (ctx!=$2) {ctx=$2; if (length(ctx) > 0) {print "[" ctx "]"}};
		
	# Whenever col 3. contains sth other than the project name, 
	# write it out as a • TASK.
	if (length($3) > 0 && $3!=$1) {print "• " $3}
}'
--

Last edited by RobTrew; 2012-08-01 at 12:30 PM..
 
Quote:
Originally Posted by drongo View Post
How do I get it to show tasks that are in a certain Single-Action list, project or folder?
A shell-script example of filtering by folder. (In this case for projects and tasks in folders with names containing the string "writ")

Code:
#!/bin/sh
#OFOC=$(osascript -e 'tell application "Finder" to get id of application file id "OFOC"')
OFOC="com.omnigroup.OmniFocus" # For Appstore-purchased variant use (slower) line above instead
echo "SAMPLE LISTING:"
sqlite3 $HOME/Library/Caches/$OFOC/OmniFocusDatabase2 '
SELECT f.name, p.name,c.name, tt.name 
FROM (((task t left join projectinfo pi on t.containingprojectinfo=pi.pk) tt 
left join task p on tt.task=p.persistentIdentifier) 
left join context c on tt.context = c.persistentIdentifier) 
left join folder f on tt.folder=f.persistentIdentifier
WHERE tt.dateCompleted is null and f.name like "%writ%"
ORDER BY f.name, p.name, c.name'| awk '
BEGIN {FS="\|"; fldr=0; prj=0; ctx=0;}
{
	# Whenever the value of col. 1 changes, 
	# write it out as a FOLDER header,
	if (fldr!=$1){fldr=$1; if (length(fldr) < 1) {print "\n(No folder)"} 
	else {print "\n[Folder: " toupper(fldr) "]"}};
		
	# and whenever the value of col. 2 changes, 
	# write it out as a PROJECT header.
	if (prj!=$2){prj=$2; if (length(prj) < 1) {print "\n\t(INBOX)"} 
	else {print "\n\t" toupper(prj)}};
	
	# Whenever the value of col. 3 changes, 
	# write it out as a [CONTEXT] sub-header.
	if (ctx!=$3){ctx=$3; if (length(ctx) > 0) {print "\t[" ctx "]"}};
		
	# and whenever col 4. contains sth other than the project name, 
	# write it out as a • TASK.
	if (length($4) > 0 && $4!=$2) {print "\t• " $4}
}'

Last edited by RobTrew; 2012-08-01 at 12:31 PM..
 
Quote:
Originally Posted by drongo View Post
How do I get it to show tasks that are in a certain Single-Action list, project or folder?
Single-Action holders with names containing the string "misc"

Code:
#!/bin/sh
#OFOC=$(osascript -e 'tell application "Finder" to get id of application file id "OFOC"')
OFOC="com.omnigroup.OmniFocus" # For Appstore-purchased variant use (slower) line above instead
echo "SAMPLE LISTING:"
sqlite3 $HOME/Library/Caches/$OFOC/OmniFocusDatabase2 '
SELECT f.name, p.name, c.name, tt.name 
FROM (((task t left join projectinfo pi on t.containingprojectinfo=pi.pk) tt 
left join task p on tt.task=p.persistentIdentifier) 
left join context c on tt.context = c.persistentIdentifier) 
left join folder f on tt.folder=f.persistentIdentifier
WHERE tt.dateCompleted is null and tt.containsSingletonActions=1 and p.name like "%misc%"
ORDER BY p.name, c.name' | awk '
BEGIN {FS="\|"; fld=0; prj=0; ctx=0;}
{
	# Whenever the value of col. 1 changes, 
	# write it out as a FOLDER header,
	if ( fld!=$1) { fld=$1; if (length( fld) < 1) {print "\n(No folder)"} 
	else {print "\n[Folder: " toupper( fld) "]"}};
		
	# and whenever the value of col. 2 changes, 
	# write it out as a PROJECT header.
	if (prj!=$2) {prj=$2; if (length(prj) < 1) {print "\n\t(INBOX)"} 
	else {print "\n\t" toupper(prj)}};
	
	# Whenever the value of col. 3 changes, 
	# write it out as a [CONTEXT] sub-header.
	if (ctx!=$3) {ctx=$3; if (length(ctx) > 0 && length($4) > 0) {print "\t[" ctx "]"}};
		
	# and whenever col 4. contains sth other than the project name, 
	# write it out as a • TASK.
	if (length($4) > 0 && $4!=$2) {print "\t• " $4}
}'

Last edited by RobTrew; 2012-08-01 at 12:37 PM..
 
A shell script version of Due Soon, illustrating an approach to listing imminently due tasks with their due date (+time) and number of remaining days, in NerdTool GeekTool etc

Code:
#!/bin/sh
#OFOC=$(osascript -e 'tell application "Finder" to get id of application file id "OFOC"')
OFOC="com.omnigroup.OmniFocus" # For Appstore-purchased variant use (slower) line above instead
echo "DUE SOON:"
OFQUERY="sqlite3 $HOME/Library/Caches/$OFOC/OmniFocusDatabase2"
YEARZERO=$($OFQUERY "SELECT strftime('%s','2001-01-01')")
NOW=$($OFQUERY "SELECT (strftime('%s','now', 'localtime'))")
DUE="($YEARZERO + tt.effectiveDateDue)"
DAY=86400
DAYS_LEFT="round((($DUE-$NOW)*1.0)/$DAY,1)"
DAYS_OVERDUE="($NOW-$DUE)/$DAY"

$OFQUERY "
SELECT f.name, p.name, c.name, tt.name, $DAYS_LEFT, strftime('%m-%d %H:%M',$DUE, 'unixepoch') 
FROM (((task t left join projectinfo pi on t.containingprojectinfo=pi.pk) tt 
left join task p on tt.task=p.persistentIdentifier) 
left join context c on tt.context = c.persistentIdentifier) 
left join folder f on tt.folder=f.persistentIdentifier
WHERE tt.isDueSoon=1 and $DAYS_OVERDUE < 14
" | awk '
BEGIN {FS="\|"; fld=0; prj=0; ctx=0;}
{
	# Whenever the value of col. 1 changes, write it out as a FOLDER header,
	if ( fld!=$1)  { fld=$1; if (length( fld) < 1) {print "\n(No folder)"} 
	else {print "\n[Folder: " toupper( fld) "]"}};
		
	# and whenever the value of col. 2 changes, write it out as a PROJECT header.
	if (prj!=$2)  {prj=$2; if (length(prj) < 1) {print "\n\t(INBOX)"} 
	else {print "\n\t" toupper(prj)}};
	
	# Whenever the value of col. 3 changes, write it out as a [CONTEXT] sub-header.
	if (ctx!=$3)  {ctx=$3; if (length(ctx) > 0) {print "\t[" ctx "]"}};
		
	# and whenever col 4. contains sth other than the project name, write it out as a • TASK.
	if (length($4) > 0 && $4!=$2) {print "\t• " $4, "("$5" days to "$6")"}
}'

Last edited by RobTrew; 2012-08-05 at 07:39 PM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stencil: Custom circles of arrows (Shape with script Action) RobTrew OmniGraffle Extras 1 2013-07-29 07:28 PM
Single-Action Lists zakgottlieb OmniFocus 1 for Mac 2 2012-08-09 07:14 AM
Script to dump Omnifocus Context lists to Kindle? profdrhabeb OmniFocus Extras 2 2011-05-17 04:10 AM
Script to convert OmniOutliner row to OmniFocus Action JohnJ80 OmniOutliner 3 for Mac 0 2011-05-13 07:38 PM
On desktop banner of current action fathom OmniFocus 1 for Mac 26 2010-12-13 03:33 AM


All times are GMT -8. The time now is 02:27 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.