Very cool script - thanks for that!
I’ve personally gone for the growl notification, and putting the script somewhere quicksilver can find it so ‘cmd-space top’ brings it up
Note: This post is over 10 months old. You may want to check later in this blog to see if there is new information.
The following links are auto-generated but may help you locate newer content:
I started digging through the sqlite3 database for iGTD to see what fun I could have with it. Here’s a little ruby script that, in combination with quicksilver, will pop up a large type window of your top 5 next actions…
It should be noted that this script is not a life-changer. It’s an example of what could be done with the extensive database that iGTD keeps. The database is quite complete and stores all of the necessary information for an external program to find, sort and display tasks, notes, links, etc. This script simply finds the tasks listed as Next Actions, sorts them by Priority and then shows the first 5, or as many as there are if there are less than 5.
Here’s the script: top5.zip.
You’ll need rubygems, or the ability to install the sqlite3 library and modify the script yourself. It’s not a hard library to install, and can be found at RubyForge if you choose that route. If you have rubygems, just type sudo gem install sqlite3-ruby at a terminal prompt, enter your password and you should be ready to run.
You’ll also need to know your ruby environment and location, and change the shebang line in the script as necessary.
If you want to use the sync backup file instead of the main database, you’ll need to edit the dbToUse variable in the script.
There are comments in the script for making it work with growl instead of quicksilver’s large type feature. The only addition you’ll need is the Escape library for ruby, which you can install with sudo gem install escape. Then just uncomment the growl lines and comment out the “print output” lines.
Once you’ve satisfied the above requirements, the easiest way to run the script is with a Quicksilver trigger. From terminal, make the script executable (chmod 777 top5.rb) and then place it in your home Applications directory (/Users/yourname/Applications). Now open Quicksilver (⌃-Space) and go to triggers with ⌘-‘. Go to custom triggers and click the plus button at the bottom and select Hotkey. Enter this as your trigger:
tell application "Quicksilver" to show large type " Top 5 Next Actions:
" & (do shell script "~/Applications/top5.rb")
Note that that is a tilde before /Applications (for your home directory). The line break after Actions: will be important for formatting.
Set the Action to “Run as Applescript” and save it. Assign a hotkey by double clicking in the hotkey column and clicking where it says “Set Keys”. Type your key combination (I use ⌥-⌘-N).
That’s it. If everything is in order, you should be able to type your key combo and quickly view your next actions. I’m not going to offer a ton of support on this script because, as I said, it’s an example and I’m offering it up as an inspiration for those who would take it to the next level. I’ll continue to play and as I come up with more useful ideas for it, I’ll see if I can make it less of a pain to install.
If you change the script to work with growl by rearranging the comments, you no longer need the quicksilver trigger but can run the script directly as a program. The growl window that pops up will have an iGTD icon and will be sticky (stay until you click it).
Here’s the full text of the script for reference:
#!/usr/local/bin/ruby## Created by Brett Terpstra on 2007-06-29.# Copyright (c) 2007. All rights reserved.# requires sqlite3-ruby, which can be installed via rubygems# > sudo gem install sqlite3-ruby## If you want to use growl uncomment the escape require and the growlnotify lines,# and coment out the print output lines. You'll need to install the escape gem:# > sudo gem install escape# Then you can run the script directly from quicksilver without an applescript trigger.require 'rubygems'require 'sqlite3'#require 'escape'dbToUse = "#{ENV['HOME']}/Library/Application Support/iGTD/iGTD.sql"db = SQLite3::Database.new( dbToUse )rows = db.execute( "SELECT task.ZNAME,project.ZNAMEFROM ZTASK AS task, ZPROJECT as projectWHERE task.ZPARENTPROJECT = project.Z_PKAND task.ZNEXTACTION = '1'AND task.ZMAYBE = '0'AND task.ZCLEANEDUP = '0'AND task.ZWAITINGFOR = '0'AND task.ZPRIORITY = '1'" )output = ""count = 1rows.each do |task,project|output += "#{count}. #{task}\r [#{project}]\r"if count == 5# %x(/usr/local/bin/growlnotify -m #{Escape.shell_command(output)} -t "Top 5 Next Actions" -s -a "iGTD")print outputexitendcount += 1end#{}%x(/usr/local/bin/growlnotify -m #{Escape.shell_command(output)} -t "Top 5 Next Actions" -s -a "iGTD")print outputVery cool script - thanks for that!
I’ve personally gone for the growl notification, and putting the script somewhere quicksilver can find it so ‘cmd-space top’ brings it up
Yes, that’s probably my preference as well. I just wanted to offer an option for once that required as few external programs as possible ;).
So I’m trying to get this thing to work. I have everything installed and all the paths set up correctly, but if I edit the script to use the Growl notification, I get this in the console:
/Users/rcn/Applications/top5.rb:39: unknown regexp options - lcal
/Users/rcn/Applications/top5.rb:39: syntax error
{}%x(/usr/local/bin/growlnotify -m #{Escape.shell_command(output)} -t “Top 5 Next Actions” -s -a “iGTD”)
^
2007-07-09 04:40:15.931 Quicksilver[18572] Task failed.
And my script looks like:
#!/usr/bin/ruby
#
require 'rubygems'
require 'sqlite3'
require 'escape'
dbToUse = "#{ENV['HOME']}/Documents/Personal/iGTD.sql"
db = SQLite3::Database.new( dbToUse )
rows = db.execute( "SELECT task.ZNAME,project.ZNAME
FROM ZTASK AS task, ZPROJECT as project
WHERE task.ZPARENTPROJECT = project.Z_PK
AND task.ZNEXTACTION = '1'
AND task.ZMAYBE = '0'
AND task.ZCLEANEDUP = '0'
AND task.ZWAITINGFOR = '0'
AND task.ZPRIORITY = '1'" )
output = ""
count = 1
rows.each do |task,project|
output += "#{count}. #{task}r [#{project}]r"
if count == 5
%x(/usr/local/bin/growlnotify -m #{Escape.shell_command(output)} -t "Top 5 Next Actions" -s -a "iGTD")
# print output
exit
end
count += 1
end
{}%x(/usr/local/bin/growlnotify -m #{Escape.shell_command(output)} -t "Top 5 Next Actions" -s -a "iGTD")
# print output
Any ideas anyone? I’m probably just being stupid, so feel free to let me know that.
Thanks, Ryan
First thing I would try is removing the pair of curly brackets on line 39 before the %x. Everything else appears fine to me at first glance…
Ah, yes. That is it. Thanks.
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>
5 Comments
Jump to comment form | comments rss [?] | trackback uri [?]