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


OVERVIEW
It can be useful to glance at a key action list on the desktop, without having to fire up OmniFocus and choose a perspective. (A due now list perhaps, or due soon, or a context list, or simply the inbox, as a spur to getting it clear).

This post splits off from another thread which began by discussing ways of displaying a desktop banner of the current action, and drifted off topic towards Geektool.

I posted a couple of rather rudimentary scripts to that thread (for getting particular - unformatted and unwrapped - OF lists into a Geektool window), but here is a much more general script which enables you to attach a range of customized list specifiers to one or more Geektool 'windows' (shell geeklets) at the same time.
FUNCTION
Displays one or more custom action lists (or project lists) on your desktop, even when OmniFocus isn't running, using GeekTool.

The lists can be wrapped to fit the geeklet window, shifted to upper case, or generally modified by piping them through shell commands.
LIST DEFINITIONS
Some simple queries are pre-defined by the script,
in inbox
due soon
due now
next action
in context <Context Name>
in context "Phone"
in context "Library"
selected actions

[selected actions does, of course, require OmniFocus to be running - it lists the actions currently selected in the OF GUI]
and these can all be modified, for example to adjust sort order,
in inbox order by dateAdded
in inbox order by dateAdded DESC
in inbox order by dateDue, dateAdded
due now order by effectivedateDue
next action order by effectiveDateDue
in context "Library" order by task.name

and/or further restrict contents.
next action and flagged=1
next action and flagged=0 order by effectiveDateDue
Their format can be adjusted by piping them through further shell commands, like fold and tr.
Wrapping with 'fold'
inbox order by dateDue, dateAdded | fold -s -w 50
in context "Phone" | fold -s -w 30
Shifting to upper case with 'tr'
due now order by effectiveDateDue | tr "[:lower:]" "[:upper:]" | fold -s -w 40
active selections order by name | tr "[:lower:]" "[:upper:]" | fold -s -w 40
(or anything else which can be achieved by piping to another shell command).
More sophisticated queries can be devised in Sqlite SQL.
Project / Projects is a pre-defined alias,
and a set of relative date expressions can be used in the SQL clauses.
yesterday, today, now, soon
<jan> ... <dec> (Interpreted as references to midnight at the start of the first day of the next (or current) month of that name).

today +1w, now +2d etc.
PRECEDING THE LIST WITH A HEADER
The default list header is $Q ($N) & return where $Q is a variable representing the query, and $N is the number of matches.
In addition, a custom header can now be specified for a List/Geeklet by following the query with the switch --header= followed by an unquoted string, optionally including $Q or $N
e.g.
  • Due Soon --header=$Q [$N matches]: | fold -s -w 40
  • task where flagged=1 order by projectinfo, dateDue --header=Flagged ($N)\n | fold -s -w 40
  • or simply (to display no header at all) Active Selections --header= | fold -s -w 40

Note that additional blank lines in (or at the end of) the header can be specified as \n
INSTALLATION
  1. Choose a home for this script (if you put it in the OmniFocus script directory it will appear in the OF script menu, and can be installed on the OF toolbar). (~/Library/Scripts/Applications/Omnifocus )
  2. Install Geektool http://projects.tynsoe.org/en/geektool/
  3. Drag one or more shell windows from the GeekTool preference pane onto your desktop, select each of your shell windows in turn, and use the properties dialog to assign it:
    • A name (at the top of the properties dialog - it says "optional" but this script needs each of your Geeklets to have a name).
    • The colours and font that you want (not urgent, these can be changed later),
    • A time out period of 5 seconds, and refresh interval of 10+ seconds. (lists that won't change rapidly can obviously be refreshed less frequently).

      (Note that there is no need to assign a command - that will be done automatically by this script.)
  4. Launch this script.

USAGE
  1. Run this script,
  2. choose a shell geeklet from the list that appears,
  3. and respond the prompt by typing the name of a simple or modified query.
It may be helpful to begin your experimentation by simply accepting the default query which is offered.
If an error message appears in your geeklet, run this script again and carefully check the spelling and syntax of your list description.
Attached Files
File Type: zip OF-GeekTools3.zip (44.8 KB, 1152 views)

Last edited by RobTrew; 2012-01-25 at 11:41 AM..
 
I have updated the code above to ver 0.3 which simplifies the customization or suppression of custom headers for each list/geeklet.

(See the new section (above) under the heading "PRECEDING THE LIST WITH A HEADER")

I have also assembled some sample geeklets which can be installed directly by double-clicking them (as long as GeekTool as been installed on your system, and you have copied the theGeekOFSQL.scpt to your OmniFocus script folder).

(See the geeklets zip attached below - note that these require installation of the script in Post 1 above)

OVERVIEW OF THE GEEKLETS

These are pre-fabricated samples of the kind of Geek Tools shell geeklet that can be be run with the GeekOFSQL.scpt applescript.

They are not guaranteed to be useful, and are intended simply to provide a quick way of trying out the script.

Each of them displays a different list from your OmniFocus data. With the exception of the Active Selections geeklet, they do not need Omnifocus to be running.

The colors and font sizes etc may need to be adjusted for your desktop.


INSTALLATION

1. Install GeekTool from http://projects.tynsoe.org/en/geektool/

2. Copy the script GeekOFSQL.scpt to the OmniFocus scripts folder, so that its path is:

~/Library/Scripts/Applications/Omnifocus/GeekOFSQL.scpt

(where ~ represents your home folder).

[Note that this is an important step, as these geeklets depend on finding the script in that location]

3. Install any or all of the geeklet (.glet) files by double-clicking them.


REFERENCE

For reference, these Geeklets run the following commands. (The simplest way to attach or modify Geeklet commands for OmniFocus lists is, however, to run the GeekOFSQL.scpt in the Applescript script editor, and then choose the name of a Geeklet from the drop-down list).

The script can be found in the first post in this thread.

Active Selections:
osascript ~/Library/Scripts/Applications/Omnifocus/GeekOFSQL.scpt 'Active Selections --hdr=\n' | fold -s -w 60

Flagged:
osascript ~/Library/Scripts/Applications/Omnifocus/GeekOFSQL.scpt 'task where flagged=1 order by projectinfo, dateDue --header=Flagged ($N)\n' | fold -s -w 40

Next Action:
osascript ~/Library/Scripts/Applications/Omnifocus/GeekOFSQL.scpt 'Next Action' | fold -s -w 40

Due Soon:
osascript ~/Library/Scripts/Applications/Omnifocus/GeekOFSQL.scpt 'Due Soon order by effectiveDateDue' | fold -s -w 45

Due Now:
osascript ~/Library/Scripts/Applications/Omnifocus/GeekOFSQL.scpt 'Due Now order by effectiveDateDue' | fold -s -w 45

Inbox:
osascript ~/Library/Scripts/Applications/Omnifocus/GeekOFSQL.scpt 'In Inbox order by dateAdded --hdr=Inbox ($N)\n' | fold -s -w 40


--

Last edited by RobTrew; 2011-07-05 at 07:46 AM..
 
Updated the script and the sample geeklets to format longer lines as hanging indents.

(Simply by piping them through a few replacements, e.g.
osascript ~/Library/Scripts/Applications/Omnifocus/GeekOFSQL.scpt 'Next Action' | tr '\r' '\n' | fold -s -w 40 | perl -pe 's/(^[^]+)/\t\1/g' | perl -pe 's//-/g'
I'm sure there is a more elegant way :-)

--

Last edited by RobTrew; 2010-12-20 at 02:50 PM..
 
Rob, where could I find the OmniFocus SQlite specification? Is there a complete reference available?

Thank you.
 
No formal documentation that I know of, but you can put a list of the fields and their types into the clipboard with code like:

Code:
property pstrDBPath : "~/Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2"
property plstResults : {}

on run
	set text item delimiters to return
	set str to ""
	set lstTables to ({"Task", "ProjectInfo", "Context", "Folder"})
	repeat with oTable in lstTables
		set strSQL to "PRAGMA TABLE_INFO(" & oTable & ");"
		RunSQL(strSQL)
		set str to str & oTable & return & return & (plstResults as string) & return & return & return
	end repeat
	set text item delimiters to space
	
	set the clipboard to str
end run

on RunSQL(strSQL)
	set strCmd to "sqlite3 " & pstrDBPath & space & quoted form of strSQL
	
	set plstResults to (paragraphs of (do shell script strCmd))
end RunSQL
(Probably important to bear in mind that the schema can change, unannounced, between builds, and that reading the cache has been described on this forum as "at the deep end of not officially supported").
 
Warm thanks, Rob. In the meantime, and considering my lack of your SQL chops, I resorted to the open-source "SQLite Database Browser 2.0," which also facilitates inductive reasoning about the function of each key.
 
Hi Rob,

I love your Geektool scripts.

I have a question. How can I modify the script so that the "due soon" in Geektool matches the "due soon" in Omnifocus? I have "due soon" set to 2 days in Omnifocus but it seems that the "geektool" due soon is only picking up tomorrow's tasks and missing the tomorrow's tomorrow's tasks?

Thanks,

Steve
 
Good question, and I have now updated the script.

Ver .09 (post 1 in this thread, above) now automatically gets the current Due Soon interval setting, as in
OF > Preferences > Data > "Due Soon" is in the next N days
(OF does not need to be running).

--

Last edited by RobTrew; 2010-12-27 at 11:53 AM..
 
Hi Rob,

I updated the Script. This is the behavior that I am seeing with Due Soon marked to 2 days in OF Preferences:

1) Your Due Now - Only lists items that were due yesterday or earlier, which in Omnifocus is marked as Red.

2) Your Due Soon - Lists both today's items, which in Omnifocus is marked as Red, and tomorrow's items, which in Omnifocus is market as Orange. However, it misses listing the items due the day after tomorrow, which in OF are also marked in Orange.

I think there may a difference in the logic between your script and OF badges. OF considers today and earlier to be red and X number of days as per OF preference starting with tomorrow to be orange.

Am I doing something wrong?
 
Quote:
Originally Posted by sterlizzi View Post
with Due Soon marked to 2 days in OF Preferences ...

2) Your Due Soon - Lists both today's items, which in Omnifocus is marked as Red, and tomorrow's items, which in Omnifocus is market as Orange. However, it misses listing the items due the day after tomorrow, which in OF are also marked in Orange.
The difference may be in our OF settings - with:
Preferences > Data > "Due Soon" is in the next 2 days
and
Prefs > Data > Default Time for Due dates at 17:00
Today and Tomorrow are (this morning) orange on my system, and day after tomorrow is unmarked (black).
(I would expect the colouring to change at 17:00 this evening).

(Script ver 1.0, OF 1.8.2)



(Where Dec 30 is day after tomorrow)

My understanding of Orange and Red in OF is:

[Orange]-> ('Due Soon' in the script)
tasks where (completed is false) and (due date > now) and (due date < soon) and (((status of its containing project is active) and (effectively hidden of folder of its containing project is false or folder of its containing project is missing value)) or (in inbox is true))
[Red]-> ("Due Now" in the script)
tasks where (completed is false) and (due date < now) and (((status of its containing project is active) and (effectively hidden of folder of its containing project is false or folder of its containing project is missing value)) or (in inbox is true))
(The Sqlite SQL clauses in the script aim to match this).

There may be some subtlety here that is eluding me. Do you have a different Default Time setting, for example ?
At what time of day does there seem to be a mismatch ?

--

Last edited by RobTrew; 2010-12-28 at 03:43 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 06:43 AM.


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