Category ArchiveApplication Scripting



Apple &Application Scripting &Programming Languages 05 Apr 2006 04:17 pm

Say No Evil. Hear No Evil.

OS X of course has speech integrated into everything, and some of the voices even sound OK. I prefer Vicki.

Turns out there is also a commandline utility, called ‘say’, that will speak whatever text you pass to it.

SAY(1) Speech Synthesis Manager SAY(1)

NAME

say - Convert text to audible speech

SYNOPSIS

say [-v voice] [-o out.aiff] [-f file | string ...]

DESCRIPTION

This tool uses the Speech Synthesis manager to convert input text to
audible speech and either play it through the sound output device cho-
sen in System Preferences or save it to an AIFF file.

Well, after the fun of my sister and I each using our machines in realtime trying to do rounds of “row row your boat” with poor but hilarious results, I decided to do some scripting of ‘say’ with Ruby.

#!/usr/local/bin/ruby
day = Time.now.strftime('%A, %B %d, %Y')
%x{say -v Vicki 'Today is #{day}'}

Note: I have upgraded my Ruby installation since Apple’s Ruby 1.8.2 in Tiger is broken. You can still use this if you haven’t upgraded by changing back to #!/usr/bin/ruby. For some reason, #!/usr/bin/env ruby doesn’t work when I bundle this into an application (which comes next).

Anway, this Ruby script executes the ‘say’ command, passing it today’s date.

That’s fun, but then I wanted to bundle it so my mom could use it. The Apple application bundle format is really just a directory structure underneath a directory, called <appName.app>.

So, I created a directory structure, called ‘saytime.app’, inside I put the following folder structure:

I put my ruby script file inside the MacOS Folder.

The file, ‘Info.plist’, tells OS X what to do with the file, so I made it look like so to specify the script as the executable:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>CFBundleExecutable</key>
<string>saytime</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.3.0</string>
</dict>
</plist>

The important lines are:

<key>CFBundleExecutable</key>
<string>saytime</string>

and

<key>CFBundlePackageType</key>
<string>APPL</string>

These say, “this is an app (APPL) and the executable is “saytime”. That worked great.

Then I wanted to package it into a disk image to make it easy to copy and install since it is a bundle composed of directories.

Inside Applications/Utilities there is an application, called DiskUtility, that will create disk image files for you. This is the standard mac pkg install model.

I created a folder, called, ‘saytime’.
I copied the saytime.app into it.
I open the DiskUtility and chose File/New Disk Image From Folder.
I chose the new saytime folder.
I saved it as ‘saytime’.
That’s it.

Here’s a copy of saytime.dmg.

Pretty easy. Actually, I am sure there a many easier ways to do this, and I would be glad to hear about them.

Apple &Application Scripting &Software 05 Apr 2006 03:07 pm

Omni Group Tools

I have probably blogged about Omni Outliner or Omni Graffle in the past, but it bears repeating that these are really useful tools and they are well-built. The Omni Group has been building Cocoa apps for a long time. To the point where they have released toolkits for Cocoa programmers of the foundations that they extracted from their applications.

Omni Graffle is great for those quick little diagrams that you need to make to show someone a design idea. The only drawback is that they look so stylish that you end up having a conversation about the tool as much as the design idea.

It provides several stencil sets and there are many third party stencils available as well.

Ryan Davis of the Seattle Ruby Brigade has a presentation on automatically generating Rails model schemas with OmniGraffle and AppleScript. He hasn’t released the source, but it shouldn’t be too much to recreate, and it might be even easier using the migrations facilities in rails.

As for Outliner, I use it for creating all kinds of lists, and use it as my day planner as well. It also has third party extensions. There are even extensions to setup a Getting Things Done planning system, though I have not ventured to try it yet as my little setup works pretty well.

I like the sense of humor of the Omni Group as well. Here’s one sample, the description for a set of AppleScript extensions states:

Useful Scripts is a collection of AppleScripts for OmniOutliner that will really help you perform certain actions much more quickly. They also serve as a great way to familiarize yourself with OmniOutliner’s AppleScript interface in case you’d like to write a script to help with your evil plan to conquer the universe, or something.

With the Applescripts you can supposedly pipe your lists into OmniGraffle and make diagrams as well. Nifty.

Application Scripting 31 Mar 2006 08:45 am

AppScripting.com and MediaWiki

I finally set up AppScripting. I wanted it to support itself if possible, so I also setup Google Ads on it. I used the MediaWiki software that powers the WikiPedia to run the site. Integrating Google Ads into the right side of the layout turned out to be quite simple.

I later saw that Julio had a link to a site on setting up MediaWiki in general that looked pretty good.

Continue Reading »