Tuesday, September 14, 2010

One more change to the google voice actions

Apologies users to my Google Voice Quicksilver actions and OS X services: 

I found one more bug in the php script and killed it.

Which is good.

Bad news is there’s no way for me to update the copies of the script that are on your computers. You’ll have to do it manually by tracking down a file named “google-voice.php” and deleting it. The next time you run one the actions the script will get re-downloaded with the updated code.

The file is located in different locations for the QS Actions and the Services.

Quicksilver actions:  ~/Library/Application Support/Quicksilver/

OS X Services: ~/Library/Services/

If you’re just finding out about all of this and want in: read the original post here.

Sunday, September 12, 2010

Update for Google Voice Quicksilver actions and OS X Services

One of my first posts I released applescript actions for Quicksilver that let you easily send a SMS or initiate a phone call thru Google Voice as well as OS X (10.6 only) services that let you right click on a phone number in any application and do the same. 

Sometime in the last week the PHP script I used to work with GVoice broke. I fixed it. If you already use the QS actions and want to get them working again:

Go to “~/Library/Application Support/Quicksilver/” (“~” means your home folder) and delete “google-voice.php”. That’s it. The next time you use either the gvDialer or SMSgv actions they will automatically download the updated version.

If you already use the the OS X services you can find and delete the old “google-voice.php” file in “~/Library/Services/” folder. The next time they are run they’ll download the fixed php file.

If you’re just finding out about all of this and want in: read the original post here, the actions and services will just work.

Monday, July 26, 2010

A status update on my continuing obsession with Instapaper

Since getting Instapaper for my iPod Touch, I’ve been loving the ability to add links to my instapaper just by tapping on them, rather than (on my laptop) having to follow a link to its webpage, wait for it to load, and then hit the bookmarklet to send it to IP. So back when Snow Leopard came out I made a Service, and more recently I’ve made extensions for Safari and Chrome,  that lets you easily send articles to Instapaper.

The browser extensions enable three ways to send articles to Instapaper in the background:

1. Right-click on a link and InstapaperIt from the contextual menu

2. hold down the option/alt key when clicking on a link.

3. click the toolbar button to add the current page to instapaper.

InstapaperIt for Safari

InstapaperIt for Chrome

OS X Service:

Once installed, you can select any URL in any cocoa application, and any link in Safari and send it to Instapaper in the background. You’ll get notified via Growl or the OS. After unzipping this, you install the service by moving it to ~/Library/Services (make a Services folder in your Library if you don’t have one).

For NetNewsWire users (adds the ability to send links in NNW as well as other apps):
InstapaperIt.zip

For Everyone else:
InstapaperIt.zip

Thursday, March 18, 2010

Applescript, Services, and Growl issues

One of Snow Leopard’s great evolutions was building up Automator’s ability to create a service, which you can access from your contextual menu, and to make powerful services using Applescript.

A lot of the services I’ve been making, like sending an article to instapaper, or shortening a URL with is.gd, do their business in the background; and I’ve found it useful to throw up a growl notification when their done. The challenge is then distributing the service to users who may or may not have Growl installed. In typical applescripting, outside of writing services, the way to handle this is to check if Growl is running,

tell application “System Events”
set isGrlRunning to (count of (every process whose name is “GrowlHelperApp”)) > 0
end tell
if isGrlRunning then

end if

and if it is running to Growl a notification.

The reason this works in applescripts and not services gets into the nerdy nitty-gritty of applescripting and will make this already nerdy post, nerdier. Apologies.

There are two conditions that are important to consider when you call an application from Applescript, given that a user may or may not have that application installed. One condition is during runtime, when the user runs the applescript, and the example with Growl above works great for that.

The other condition is when the applescript is compiled, turned from a mostly natural language script into code OS X and other applications can understand. When applescript gets compiled every call to every application gets checked, and so must be installed on the machine that compiles the script.

Non-service applescripts get compiled once, and can then be distributed and run by users without needing to be recompiled. So you can write an applescript on your machine calling all kinds of applications (as long as you use code like above which checks the machine running the script to see if the application is installed before sending it commands), and then send that applescript to users who may or may not have those applications installed, and they can run it, without compiling it, and be fine.

HOWEVER. For some reason, services compile their applescripts at runtime. Which means you can’t write rich services that call many applications without worrying what’s installed on a users machine, because each time the service is run it has to check every line of applescript against every application that it calls.

So a simple thing like Growling a notification becomes a dangerous prospect if you want to distribute your services… but I’ve figured out a way around it.

The thing to do is to isolate any bits of script that call extraneous applications, that might not be installed by a user, and run them as a shell script using “osascript”. When a service is run it does not go through and check any shell scripts, including ones run in applescript via “do shell script ‘osascript …”

So here’s a handler you can use in your Applescript services to growl, safely. It’s from my InstapaperIt service. The key here is that since you’re writing a shell script all quotes need to be escaped. Also note that I end the shell script with ” &> /dev/null &”, so that the shell script is run without waiting for a response. I’ll post it below, but you can also download an applescript of it here because posting escaped quotes on the web doesn’t come out right.

on triggerGrowl(currentStatus, currentTitle)
set myApp to “APPLICATIONNAME”
try
tell application “System Events”
set isGrlRunning to (count of (every process whose name is “GrowlHelperApp”)) > 0
end tell
if isGrlRunning then
set osaSc to “tell application "GrowlHelperApp"
set the allNotificationsList to {"Notification"}
set the enabledNotificationsList to {"Notification"}
register as application "” & myApp & “" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "” & myApp & “"
notify with name "Notification" title "” & currentTitle & “" description "” & currentStatus & “" application name "” & myApp & “"
end tell”
set shSc to “osascript -e ” & quoted form of osaSc & ” &> /dev/null &”
ignoring application responses
do shell script shSc
end ignoring
end if
end try
end triggerGrowl

Thursday, November 12, 2009

Snow Leopard Service, collect files into a new folder

Here’s a snow leopard service which lets you easily collect files into a new folder. Just select files in the Finder, right click on them and go to the service menu and choose folderCollect. The service will then pop up a dialog box asking what you want to name the folder. Then it will move all the files you had selected into that folder. Download folderCollect here. Install to ~/Library/Services. (“~” refers to your home folder).

if you don’t have a Services folder in ~/Library/, then make one Update 03/2010: Mike’s comment inspired a small change to the service.

Instead of “untitled folder” as the default name of your new folder, folderCollect now uses the name of the first file (alphabetically) you’ve selected to be collected. You’ll still get a dialog box, but this will be the default name in that box, so you can just hit enter to use it.

If you want the default name to always be the case, and no dialog box, you can double click on the service to open it with Automator. The first line of script is

property askName : true

change it to false and folderCollect will stop asking for your input…


Thursday, October 15, 2009

Snow Leopard Services… pt4, text clipping

Simple services for clipping selected text to various applications. Works as advertised. Just select text, right click, pick your poison, and that text will be used in a new document in the appropriate application.

The Evernote Clippers is a .zip which also includes a service to clip any image selected in the Finder to evernote. [edit— Also includes a service which takes any URL or Hyperlink and has Evernote create a note using the webpage of that URL]

Evernote Clippers

Text to Notational Velocity

The TextMate Service makes a clumsy attempt to see if you’re clipping code and, if so, to set the documents code type appropriately.

Text to TextMate

Snow Leopard Services… pt1, shortening

I’ve been playing around with Automator’s Create Service offering for Snow Leopard. It’s pretty great to be able to fill your context menu up with useful goodies.  All you do is select the appropriate text/file/phone number/etc. and right click; the service awaits in your context menu to do your bidding.

To install just move them to your HOME/Library/Services folder. If you don’t have a folder named “Services” in your Home/Library/ then create one, and move the shortening service there.

Here’s three that take URLs selected in any application and creates shortened URLs, puts them on your clipboard, and notifies you via Growl or the OS. Also works with links selected in Safari.

For NetNewsWire users (adds the ability to shorten links in NNW as well as other apps):

for tr.im shortened URLs

for adjix

for is.gd

for bit.ly

for thurly

For Everyone else:

for tr.im shortened URLs

for adjix

for is.gd

for bit.ly

for thurly

Snow Leopard Services… pt3, Google Voice

Seemless integration of Google Voice into Snow…

Select a phone number in any application, right click, select the services sub-menu, and choose either gvDialer or SMSgv to initiate a phone call or send a text message through your Google Voice account.

If texting, a dialog box will pop up for you to type in your message.

Growl will growl (if you’re a growler) upon dialing/sending the message.

The first time you run this the service will ask you to enter your Google Voice account info (it’ll get stored in your Keychain). The services also require a php script to do the heavy lifting and you’ll get asked about installing that to your Home/Library/Services folder.

gvDialerServices.zip

There’s also Quicksilver actions that do the same thing. Once installed:

Activate Quicksilver, and either enter a phone number in QS’s text entry mode, or use QS to search your Address Book and find a phone number.  The point being to get a phone number into QS’s first pane. 

Tab over to QS second pane and type till you see either gvDialer or smsGV (depending on what you want to do, dial or text). and hit enter. If you’re texting a dialog box will appear allowing you to enter your text message.

To install: download and unzip the following file below, move the two actions smsGV.applescript and gvDialer.applescript to   ~/Library/Application Support/Quicksilver/Actions/   (where ~ means your home folder, and if you don’t already have a folder in Application Support/Quicksilver/ named actions, make one, and put the two files there. Restart Quicksilver and you should be good to go.

gvQSactions.zip