What’s this all about then?
rb-appscript is a powerful way to automate your Mac. It's similar to Applescript but it's built in Ruby, which means you get to leverage that language's powerful syntax and libraries. Giving you more time to make toasted sandwiches. You want long-winded explanations? We got those.
Please note that these scripts are by no means bulletproof, and are intended to provide examples of application scripting. I take no resposibility for any loss of data or mishaps; you download and run everything at your own risk. That said, I use all of these scripts in a production environment every day (well – more accurately, I use some of these scripts in a production environment most days).
Things: Add NetNewsWire Headline
This script (which is based on this one by Mike Hall) creates a new To Do in Things based on the currently selected headline, gives it a couple of tags to make it easy to find again, and embeds the URL in the notes section. So you can save up all your Internetistractions (and yes, that is a clumsy neologism/portmanteau of my own creation) and consume them when you’re not supposed to be working.
The source code is hastily finishing its breakfast and pulling on its gumboots, just south of here.
#!/usr/bin/env ruby # coding: utf-8 # Ian Haigh - thejoyofappscript.com # Make a new To Do in Things, based on the name and URL of the currently # selected item in NetNewsWire. The new To Do goes slap bang into the "Someday" # category. Handy for temporary bookmarks for things that you want to check # out later but aren't suitable for Instapaper, like video. # Based on this script by Mike Hall: # http://mph.puddingbowl.org/2010/07/creating-links-in-the-body-of-a-note-in-things/ TAGS = "nnw, watch" # tags that get added to the new To Do def create_to_do(name, source, link) if link == "" note = name else note = "[url=#{link}]#{name} - #{source}[/url]" end task = @things.make(:at => app.lists["Someday"].beginning, :new => :to_do, :with_properties => { :name => "#{source} – #{name}", :tag_names => TAGS, :notes => note, }) end require 'rubygems' require 'appscript' include Appscript nnw = app("NetNewsWire") @things = app("Things") name = nnw.selectedHeadline.title.get link = nnw.selectedHeadline.URL.get source = nnw.selectedHeadline.subscription.givenName.get create_to_do(name, source, link) #`growlnotify -p 1 -m "Added \"#{name}\" to things."` # uncomment the previous line if you've got Growl installed # and you want a pretty message to pop up.