07.14.06

GeekTool rocks

Posted in Mac OS X at 10:58 pm by Haris

Dr. Drang’s recent post prompted me to finally talk about GeekTool, which I first learned about from Allan.

What does this amazing tool do? Something very simple actually, it allows you to project the results of a command, or the contents of a file, or some picture from your computer or a url, on your desktop, permanently, allowing you to also shift between different groups of such things. It’s absolutely wonderful. I now have it, in six different small windows, run a command that scans my gtdalt files for particular contexts and assembles them into a nice list, which it then shows me. So the moment I press F11, I get to see all my actions that need to be done! How cool is that, eh? Another common use is to have the output of the console there, so that you can track what is happening in your computer. Dr. Drang, and now I, uses it to have a little weather-widget kind of think of his desktop. I would kill my weather widget completely and save myself some memory, except I really like the week preview that it does. If only…

Later

5 Comments »

  1. Richard said,

    July 17, 2006 at 7:19 am

    So, pray tell, what is the command you run in geektool that scans your gtdalt files?

  2. Haris said,

    July 17, 2006 at 7:38 am

    @Richard,

    well it’s nothing special, so I didn’t bother much with it. Here is its code:

    #!/usr/bin/env ruby
    gtdpath, context, *options = ARGV
    textArray = ["BANNER Context #{context.upcase}:%"]
    filenames = Dir["#{gtdpath}/*.gtd"]
    for filename in filenames do
      File.open(filename) do |f|
        f.readlines.each do |line|
          textArray << "MSG "+$1.gsub(/[(d{4}-d{2}-d{2})]/,"\1") +"%" if line =~ /s*@#{context}s+(.*)$/
        end
      end
    end
    puts textArray.join("n")
    

    I’ve saved it under ~/bin with the name show_context, and then in GeekTool I run a command like: “/Users/haris/bin/show_context /Users/haris/Documents/MyGTD email | /usr/local/bin/remind -”. One such command on each window that I want the actions for some context to show up. I’ve got like 8 such windows, one for each of my contexts. It’s not very polished, but it does its work. The only thing I should point out about the above code is the presence of the gsub. This is essential, because Remind interprets things in brackets as expressions to evaluate, and we don’t want our date evaluated as if it were a numeric expression. Another developer has sent me another version that is perhaps a bit more polished, but I haven’t had much time to look at it yet.

    Of course, in this simple case, you don’t really need to send things through remind. I’ve done it that way because I was hoping to make it a bit more elaborate.

  3. Haris said,

    July 17, 2006 at 12:09 pm

    Brad Miller is the other developer, and I see he has made his script public here

  4. Kai von Fintel said,

    July 18, 2006 at 5:51 am

    I’m glad you’re sharing the code for this command. I just tried it out and received this error message:

    invalid regular expression: /[(d{4}-d{2}-d{2})]/

  5. Haris said,

    July 18, 2006 at 7:14 am

    @Kai,

    sorry i have some problems when pasting code in my blog, it removed a bunch of backslashes. There should be backslashes right before the two square brackets, as well as in front of every d. Also in the line =~ .. part, the two s’s appearing should have a backslash in front of them as well. I think that’s all.

Leave a Comment