<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Zzot&#039;s Weblog &#187; AppleScript</title>
	<atom:link href="http://zzot.net/-/applescript/feed/" rel="self" type="application/rss+xml" />
	<link>http://zzot.net</link>
	<description>If you can read this, you&#039;re following too close.</description>
	<lastBuildDate>Mon, 26 Oct 2009 02:12:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Snow Leopard</title>
		<link>http://zzot.net/2009/09/02/snow-leopard/</link>
		<comments>http://zzot.net/2009/09/02/snow-leopard/#comments</comments>
		<pubDate>Wed, 02 Sep 2009 15:40:46 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Leopard]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Snow Leopard]]></category>

		<guid isPermaLink="false">http://zzot.net/?p=345</guid>
		<description><![CDATA[So, Erwin posted his first impressions list, which reminded me that I&#8217;ve done one of my own from time to time, so here goes. I didn&#8217;t do a regular upgrade, and even then I don&#8217;t really remember how long it &#8230; <a href="http://zzot.net/2009/09/02/snow-leopard/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So, <a href="http://is-here.com/archives/2009/08/29/835/">Erwin</a> posted his <em>first impressions</em> list, which reminded me that I&#8217;ve done one of my own from time to time, so here goes.</p>

<p>I didn&#8217;t do a regular upgrade, and even then I don&#8217;t really remember how long it took last time,<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> so I have no idea if it installed any faster.  DiskWarrior seemed to be getting lost scanning my hard drive, so I did the <em>format, install, restore</em> dance.  The installer&#8217;s install/restore mode didn&#8217;t seem to be working either, did those two separately.<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup>  My free-space story seems much like Erwin&#8217;s, with an additional uncertainty point thrown in for good measure — Migration Assistant copied over my old <tt>/Developer</tt> directory (with a new name), so I had two copies of the developer tools installed for a while.</p>

<p>All that being said, here are a few things that I&#8217;ve noticed:</p>

<h4>Pros</h4>

<ul>
<li><a href="http://www.apple.com/macosx/what-is-macosx/mail-ical-address-book.html">Mail</a> seems a lot faster.</li>
<li>All of my <a href="http://www.apple.com/macosx/what-is-macosx/apps-and-utilities.html#dashboard">Dashboard</a> widgets survived.</li>
<li>Mercifully, iPhone developers no longer have to download the entire
developer tools package every time they want a new iPhone OS SDK.<sup id="fnref:3"><a href="#fn:3" rel="footnote">3</a></sup></li>
</ul>

<h4>Cons</h4>

<ul>
<li>None of my Menu Extras survived.</li>
<li>Imagine, for a moment, that you had put Script Editor in its own
Library (Window Menu → Library) under Leopard or other cats prior.
You might have thought that you would now have an <a href="http://www.apple.com/macosx/what-is-macosx/apps-and-utilities.html#scripteditor">AppleScript Editor</a>
reference in there.  You&#8217;d have been wrong.  Instead, you&#8217;d now
have a grayed-out, iconless reference to Script Editor.</li>
<li>My nearby PC is still just as confused when I use “&#96;” inside the window
switcher<sup id="fnref:4"><a href="#fn:4" rel="footnote">4</a></sup> as it was before I upgraded my Mac to Snow Leopard.</li>
</ul>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>I frequently start the OS install and then go do something else
  while it cooks.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:2">
<p>Possibly due to impatience more than anything else.&#160;<a href="#fnref:2" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:3">
<p>Admittedly, this is mentioned other prominent places, but it&#8217;s
  worth repeating.&#160;<a href="#fnref:3" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:4">
<p>Alt-Tab, and if you&#8217;re running Vista or newer, Windows-Tab as well.&#160;<a href="#fnref:4" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://zzot.net/2009/09/02/snow-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ThisSpace</title>
		<link>http://zzot.net/2007/11/08/thisspace/</link>
		<comments>http://zzot.net/2007/11/08/thisspace/#comments</comments>
		<pubDate>Thu, 08 Nov 2007 17:32:56 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Leopard]]></category>
		<category><![CDATA[Mac OS X]]></category>

		<guid isPermaLink="false">http://zzot.net/2007/11/08/thisspace/</guid>
		<description><![CDATA[One of the first things that happened to me in Spaces that irked me was its auto-switching to another space when I didn&#8217;t want it to. Sure, that&#8217;s probably what I&#8217;d want it to do a lot of the time, &#8230; <a href="http://zzot.net/2007/11/08/thisspace/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of the first things that happened to me in Spaces that irked me was its
auto-switching to another space when I didn&#8217;t want it to. Sure, that&#8217;s
probably what I&#8217;d want it to do a lot of the time, but if I&#8217;m trying to open
a new window for an app that already has windows in other spaces, I have to
select that app, create a new window, grab its title bar, and move back to
the space I was in when I selected the app.</p>

<p>I was wondering what would happen if you could create a new window without
activating the app, so I typed this into Script Editor:</p>

<pre><code>tell application "iTerm"
set term to (make new terminal)
tell term
    launch session "default session"
    activate
end tell
end tell
</code></pre>

<p>{: lang=applescript }</p>

<p>The result is a brand new iTerm window in my current space, without regard to
whether there might already be such a window in another space.  Switching
spaces from a script is pretty easy too — as long as you aren&#8217;t holding down
any modifiers when the script runs (say, by having used command-r in Script
Editor):</p>

<pre><code>tell application "System Events"
    delay 1 -- so I can let go of command
    keystroke "2" using control down
    delay 1 -- so you can see one switch happen and then the other
    key code 125 using control down
end tell
</code></pre>

<p>{: lang=applescript }</p>

<p>The one missing piece is moving a window — I don&#8217;t think it&#8217;s possible to drag
an object via GUI scripting, so you can&#8217;t grab the title bar of a window,
switch spaces, and then release it.  At least it might be possible to create
a fairly complex setup from a login script…if you had a lot of time on your
hands. <img src="http://zzot.net/wp-includes/images/smilies/icon_smile.gif?9d7bd4" alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://zzot.net/2007/11/08/thisspace/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>iTerm/TextMate Here</title>
		<link>http://zzot.net/2007/11/08/itermtextmate-here/</link>
		<comments>http://zzot.net/2007/11/08/itermtextmate-here/#comments</comments>
		<pubDate>Thu, 08 Nov 2007 06:08:50 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[iTerm]]></category>
		<category><![CDATA[Leopard]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[TextMate]]></category>

		<guid isPermaLink="false">http://zzot.net/2007/11/08/itermtextmate-here/</guid>
		<description><![CDATA[Yes, again. Inspired by other solutions to the same problems, here are updated versions of these scripts. The primary difference is that they&#8217;re based on Apple&#8217;s droplet sample, so you can either click on them (for the current directory) or &#8230; <a href="http://zzot.net/2007/11/08/itermtextmate-here/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Yes, again.  Inspired by <a href="http://henrik.nyh.se/2007/10/open-terminal-here-and-glob-select-in-leopard-finder">other</a> <a href="http://henrik.nyh.se/2007/10/open-in-textmate-from-leopard-finder">solutions</a> to the same
problems, here are updated versions of these scripts.  The primary difference
is that they&#8217;re based on Apple&#8217;s droplet sample, so you can either click on
them (for the current directory) or drop stuff on them and it&#8217;ll work either
way.  So, why don&#8217;t I just use his scripts, like I do his icons?  Beats me —
I updated these a week or two ago, and I&#8217;ve long since forgotten.<sup id="fnref:forget"><a href="#fn:forget" rel="footnote">1</a></sup></p>

<p><span id="more-131"></span></p>

<p>There&#8217;s compiled versions of these scripts at the end of the post.  They&#8217;re
saved as run-only application bundles, they have the icons linked above set
on them so they look all Leopard-ish, and they have <code>LSUIElement</code> set on them
so they don&#8217;t pop up in your Dock briefly when you use them.</p>

<pre><code>-- iTerm Here
-- changes inspired by
--     http://henrik.nyh.se/2007/10/open-terminal-here-and-glob-select-in-leopard-finder

on run
-- I was run normally
tell application "Finder"
    if selection is {} then
        set selectedItems to {front window's folder}
    else
        set selectedItems to selection -- as alias list
    end if
end tell
process(selectedItems)
end run

on open (theseItems)
-- Something was dropped on me
process(theseItems)
end open

on process(theseItems)
repeat with thisItem in theseItems
    tell application "iTerm"
        activate
        try
            set term to front terminal
        on error
            set term to (make new terminal)
        end try
        tell term
            set thePath to POSIX path of (thisItem as string)
            repeat until thePath ends with "/"
                set thePath to text 1 thru -2 of thePath
            end repeat
            launch session "default session"
            tell current session
                write text "cd " &amp; quoted form of thePath
            end tell
        end tell
    end tell
end repeat
end process
</code></pre>

<p>{: lang=applescript }</p>

<pre><code>-- TextMate Here
-- changes inspired by
--     http://henrik.nyh.se/2007/10/open-in-textmate-from-leopard-finder

on run
-- I was run normally
tell application "Finder"
    if selection is {} then
        set selectedItems to {front window's folder}
    else
        set selectedItems to selection
    end if
end tell
process(selectedItems)
end run

on open (theseItems)
-- Something was dropped on me
process(theseItems)
end open

on process(theseItems)
set theCommand to POSIX path of (path to resource "mate" in bundle (path to application "TextMate"))
repeat with thisItem in theseItems
    set thePath to POSIX path of (thisItem as string)
    set theCommand to theCommand &amp; " " &amp; quoted form of thePath
end repeat
do shell script theCommand
end process
</code></pre>

<p>{: lang=applescript }</p>

<p><a href="/uploads/2007/textmate-here.app.zip?9d7bd4">TextMate Here.app.zip</a> • <a href="/uploads/2007/iterm-here.app.zip?9d7bd4">iTerm Here.app.zip</a></p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:forget">
<p>While I&#8217;m at it, I&#8217;ve also forgotten what the other thing was I
       wanted to do to them before posting this.&#160;<a href="#fnref:forget" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://zzot.net/2007/11/08/itermtextmate-here/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Later that year…</title>
		<link>http://zzot.net/2007/10/15/later-that-year%e2%80%a6/</link>
		<comments>http://zzot.net/2007/10/15/later-that-year%e2%80%a6/#comments</comments>
		<pubDate>Tue, 16 Oct 2007 02:57:57 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Apple Mail]]></category>
		<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[GUI scripting]]></category>
		<category><![CDATA[top posting]]></category>

		<guid isPermaLink="false">http://zzot.net/2007/10/15/later-that-year%e2%80%a6/</guid>
		<description><![CDATA[A while back, John Gruber posted a FastScripts script to fix a loathsome Apple Mail behavior, which was shortly followed by signature-enabled improvements. Fourteen short weeks later, here&#8217;s my own version: tell application "Mail" to activate tell application "System Events" &#8230; <a href="http://zzot.net/2007/10/15/later-that-year%e2%80%a6/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A while back, <a href="http://daringfireball.net/">John Gruber</a> posted a <a href="http://www.red-sweater.com/fastscripts/">FastScripts</a> <a href="http://daringfireball.net/2007/07/non_top_posting_scripts" title="Non-Top-Posting Reply Scripts for Apple Mail">script</a> to
fix a loathsome Apple Mail behavior, which was shortly followed by
<a href="http://makkintosshu.dyndns.org/journal/non-top-posting-reply-scripts-for-apple-mail-with-signature-support">signature-enabled</a> improvements.  Fourteen short weeks later, here&#8217;s
my own version:</p>

<pre><code>tell application "Mail" to activate
tell application "System Events"
tell process "Mail"
    -- Run the regular "Reply" command
    tell menu bar 1
        click menu bar item "Message"'s menu "Message"'s menu item "Reply"
    end tell
    delay 1.0 -- Give it a chance to finish

    -- Remember what signature was selected and switch to "None"
    set blib to value of (pop up button 1 of window 1)
    if blib is not "None" then
        click pop up button 1 of window 1 -- The Signature popup
        click menu item "None" of menu 1 of pop up button 1 of window 1
        delay 0.2
    end if

    -- Delete the return Mail inserted; recreate it at the bottom where it belongs
    key code 117 -- Forward delete
    key code 125 using command down -- Command-down (skip to the end)
    key code 36 -- Return

    -- Restore the previously selected Signature
    if blib is not "None" then
        click pop up button 1 of window 1 -- Still the Signature popup
        click menu item blib of menu 1 of pop up button 1 of window 1
        delay 0.2
        key code 117 -- Mail inserts a bonus line here too
    end if
end tell
end tell
</code></pre>

<p>{: lang=applescript }</p>

<p>One drawback that I maintain from John&#8217;s original is the use of a time delay —
I have other scripts that use them, and for each of them I occasionally have
the script fail because my machine is a little busier that day.<sup id="fnref:pbook"><a href="#fn:pbook" rel="footnote">1</a></sup>  That
being said, this script usually runs correctly.</p>

<p>My improvement is how I deal with arbitrary signatures.  If you pick a
different signature (or no signature) from the popup menu in the compose
window, Mail updates the message correctly — so I just use that behavior
to do the messy bits.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:pbook">
<p>Yes I&#8217;m still using a PowerBook — what&#8217;s that got to do with anything?&#160;<a href="#fnref:pbook" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://zzot.net/2007/10/15/later-that-year%e2%80%a6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TextMate Here</title>
		<link>http://zzot.net/2007/08/24/textmate-here/</link>
		<comments>http://zzot.net/2007/08/24/textmate-here/#comments</comments>
		<pubDate>Fri, 24 Aug 2007 18:22:46 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://zzot.net/2007/08/24/textmate-here/</guid>
		<description><![CDATA[That was actually the first post in a series (of two). This one opens a new TextMate window on the selected item (if there&#8217;s a single item selected), or the current folder otherwise. This makes the script a lot shorter &#8230; <a href="http://zzot.net/2007/08/24/textmate-here/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://zzot.net/wp-content/uploads/2009/03/textmate1.png?9d7bd4" alt="TextMate Icon" title="TextMate Icon" width="128" height="128" class="alignleft size-full wp-image-250" /></p>

<p>That was actually the first post in a series (of two).  This one opens a new
TextMate window on the selected item (if there&#8217;s a single item selected), or
the current folder otherwise.  This makes the script a lot shorter (that and
there being a simple command-line TextMate launcher that I can use).</p>

<p>The instructions are the same as last time; save it as an application
somewhere you can find it, and call it “TextMate Here”.  Find it with the
Finder, copy and paste TextMate&#8217;s icon onto it, and drag it up into your
Finder toolbar.</p>

<p>If you have TextMate installed someplace strange (or have an old enough one
that it doesn&#8217;t have the <code>mate</code> command in it) it will break; if this
happens, you get to keep both pieces.</p>

<p>Here&#8217;s the script:</p>

<pre><code>on currentFolder()
    tell application "Finder"
        try
            return POSIX path of (front window's folder as text)
        on error
            return null
        end try
    end tell
end currentFolder

on selectedItem()
    tell application "Finder"
        try
            get the selection
            return POSIX path of (the result's first item as text)
        end try
    end tell
    return currentFolder()
end selectedItem

do shell script "/Applications/TextMate.app/Contents/Resources/mate '" &amp; selectedItem() &amp; "'"
</code></pre>

<p>{: lang=applescript }</p>

<p>Feedback, improvements, etc. still welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://zzot.net/2007/08/24/textmate-here/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iTerm Here</title>
		<link>http://zzot.net/2007/08/24/iterm-here/</link>
		<comments>http://zzot.net/2007/08/24/iterm-here/#comments</comments>
		<pubDate>Fri, 24 Aug 2007 18:15:01 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://zzot.net/2007/08/24/iterm-here/</guid>
		<description><![CDATA[This is, for lack of a better description, my version of the Open a Command Window Here Windows XP PowerToy. I&#8217;ve played around with doing this from the context menu, but I eventually decided I&#8217;m not fond of that approach. &#8230; <a href="http://zzot.net/2007/08/24/iterm-here/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img src="http://zzot.net/wp-content/uploads/2009/03/iterm.png?9d7bd4" alt="iTerm Icon" title="iTerm Icon" width="128" height="128" class="alignright size-full wp-image-252" /></p>

<p>This is, for lack of a better description, my version of the <em>Open a Command
Window Here</em> Windows XP PowerToy.  I&#8217;ve played around with doing this from
the context menu, but I eventually decided I&#8217;m not fond of that approach.
Since I have the toolbar visible in Finder, however, it&#8217;s pretty easy to put
a script up there and pretend it&#8217;s a real toolbar button.</p>

<p>To use it, save it as an application somewhere you can find it, and call it
“Term Here”.  Find it with the Finder, copy and paste iTerm&#8217;s icon onto it,
and drag it up into your Finder toolbar (like how you would drag it into the dock).</p>

<p>My version of this will use the path of the selected item in the front finder
window if it is a folder (and is the only thing selected).  Otherwise, it will
use the path of the Finder window itself. If you want to skip the selection
business altogether, just replace the call to <code>selectedFolder()</code> before the
last (iTerm) stanza to <code>currentFolder()</code>.  It then launches iTerm if needed,
create&#8217;s a new (empty) window if needed, opens a new tab in that window
<code>pushd</code>&#8216;s to the directory, and lists its contents for you.</p>

<p>Here&#8217;s the script:</p>

<pre><code>on currentFolder()
tell application "Finder"
    try
        return POSIX path of (front window's folder as text)
    on error
        return null
    end try
end tell
end currentFolder

on selectedFolder()
try
    tell application "Finder"
        get the selection
        set theItem to result's first item as alias
    end tell
    set theInfo to info for theItem
    if theInfo's folder then
        return POSIX path of theItem
    end if
end try
return currentFolder()
end selectedFolder

set targetPath to selectedFolder()
tell application "iTerm"
activate
try
    set term to the front terminal
on error
    set term to (make new terminal)
end try
tell term
    launch session "default session"
    tell current session
        write text "pushd '" &amp; targetPath &amp; "'"
        write text "ls"
    end tell
end tell
end tell
</code></pre>

<p>{: lang=applescript }</p>

<p>Feedback, improvements, etc. welcome.  Unless you think it should
automatically detect whether iTerm or Terminal is your default terminal
program, in which case your feedback is only welcome if you can explain a way
to detect this from AppleScript that doesn&#8217;t double the length of the script. <img src="http://zzot.net/wp-includes/images/smilies/icon_smile.gif?9d7bd4" alt=':)' class='wp-smiley' /> 
I just don&#8217;t care enough about this issue to figure out how to do it.</p>
]]></content:encoded>
			<wfw:commentRss>http://zzot.net/2007/08/24/iterm-here/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Little Bit Slower Now… (a little bit slower now…)</title>
		<link>http://zzot.net/2006/07/28/a-little-bit-slower-now%e2%80%a6-a-little-bit-slower-now%e2%80%a6/</link>
		<comments>http://zzot.net/2006/07/28/a-little-bit-slower-now%e2%80%a6-a-little-bit-slower-now%e2%80%a6/#comments</comments>
		<pubDate>Sat, 29 Jul 2006 01:06:02 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://test.zzot.net/2006/07/28/a-little-bit-slower-now%e2%80%a6-a-little-bit-slower-now%e2%80%a6/</guid>
		<description><![CDATA[When I log into my user account on my PowerBook, everything stops for a few minutes. Drops of rain stop in mid-air, the wind falls still, the clock stops ticking, and my cat stops preening himself. I&#8217;m tired of this. &#8230; <a href="http://zzot.net/2006/07/28/a-little-bit-slower-now%e2%80%a6-a-little-bit-slower-now%e2%80%a6/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When I log into my user account on my PowerBook, everything stops for a few
minutes.  Drops of rain stop in mid-air, the wind falls still, the clock
stops ticking, and my cat stops preening himself.  I&#8217;m tired of this.</p>

<p>Spurred on by <a href="http://www.macosxhints.com/article.php?story=20060717092834812" title="10.4: Stagger startup items for less system impact">these</a> <a href="http://www.macosxhints.com/article.php?story=20011210014806400" title="An AppleScript workaround for login items bug">hints</a>, I finally got around to do
something about it.  I created a folder, <code>~/Library/Login Items/</code>, dropped
aliases to applications formerly in my (very lengthy) list of regular login
items, and removed them from the OS&#8217;s list.  Then I saved the following
script as <code>Slow Launch.app</code> in that same directory:</p>

<pre><code>-- Delay before the first launch and between subsequent launches
set firstLaunchDelay to 10
set interLaunchDelay to 5

tell application "Finder"
-- Find my list of launch items
set loginItemsFolder to (container of (path to me) as alias)
set loginItemsList to loginItemsFolder's items whose kind is "Alias"

-- Set the initial delay
set launchDelay to firstLaunchDelay

-- Process the list
repeat with loginItem in loginItemsList
    -- Hurry up and wait
    delay launchDelay
    set launchDelay to interLaunchDelay

    -- Open the item; hide it if requested
    open loginItem
    if (loginItem's comment is "hide") then
        delay launchDelay
        set launchDelay to 0
        set (process ( (loginItem's displayed name) as text) )'s visible to false
    end if
end repeat
end tell
</code></pre>

<p>{: lang=applescript }</p>

<p>Add <code>Slow Launch.app</code> to the OS&#8217;s login items list, and I&#8217;m done.  I could
swear that it even takes less time to launch everything, in spite of all the
waiting the script does.  The only drawback is that not everything can taken
out of the OS&#8217;s list; some apps<sup id="fnref:witch"><a href="#fn:witch" rel="footnote">1</a></sup> helpfully put themselves back again if
you take them off the list, and others<sup id="fnref:slim"><a href="#fn:slim" rel="footnote">2</a></sup> nag you about not being in that
list whenever they&#8217;re launched.  All that being said, it still feels a lot
snappier this way.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:witch">
<p><a href="http://www.petermaurer.de/nasi.php?thema=witch&amp;sprache=english">Witch</a>, for example.&#160;<a href="#fnref:witch" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:slim">
<p><a href="http://www.orange-carb.org/SBM/">Slim Battery Monitor</a>, for example.&#160;<a href="#fnref:slim" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://zzot.net/2006/07/28/a-little-bit-slower-now%e2%80%a6-a-little-bit-slower-now%e2%80%a6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A bash script to mess with the containing Terminal.app window</title>
		<link>http://zzot.net/2005/03/27/a_bash_script_t/</link>
		<comments>http://zzot.net/2005/03/27/a_bash_script_t/#comments</comments>
		<pubDate>Mon, 28 Mar 2005 03:51:28 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://zzot.net/wp/2005/03/27/a-bash-script-to-mess-with-the-containing-terminalapp-window/</guid>
		<description><![CDATA[I found it, but I still don&#8217;t have a clue as to why I wrote it to begin with: function setgeometry { local rows=`expr "$1" : '[0-9]*x([0-9]*)$'` local cols=`expr "$1" : '([0-9]*)x[0-9]*$'` case $TERM in Apple_Terminal) window=`osascript -e 'tell app &#8230; <a href="http://zzot.net/2005/03/27/a_bash_script_t/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I found it, but I still don&#8217;t have a clue as to why I wrote it to begin with:</p>

<pre><code>function setgeometry
{
    local rows=`expr "$1" : '[0-9]*x([0-9]*)$'`
    local cols=`expr "$1" : '([0-9]*)x[0-9]*$'`
    case $TERM in
        Apple_Terminal)
            window=`osascript -e 'tell app "Terminal" to get first window'`
            #echo $window
            osascript -e 'tell app "Terminal"'
                             -e "set number of rows of $window to $rows"
                             -e "set number of columns of $window to $cols"
                         -e 'end tell'
            return $?
            ;;
        *)
            echo "Sorry, I don't know how to do that in $TERM"
            return 1
            ;;
    esac
}
</code></pre>

<p>{: lang=bash }</p>

<p>It doesn&#8217;t seem to work anymore, but the concept is still valid (i.e.,
<code>osascript -e 'tell app "Terminal"' -e 'set blib to first window' -e "get
blib's number of columns" -e 'end tell'</code> will actually tell you something,
although that&#8217;s hardly a useful example).</p>
]]></content:encoded>
			<wfw:commentRss>http://zzot.net/2005/03/27/a_bash_script_t/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beautiful</title>
		<link>http://zzot.net/2004/04/17/beautiful/</link>
		<comments>http://zzot.net/2004/04/17/beautiful/#comments</comments>
		<pubDate>Sun, 18 Apr 2004 04:02:49 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[Movable Type]]></category>

		<guid isPermaLink="false">http://zzot.net/wp/2004/04/18/beautiful/</guid>
		<description><![CDATA[AppleScript — maybe you&#8217;ve heard of it. In fact, if you&#8217;re reading my website, you&#8217;ve probably heard of it. What&#8217;s cool about AppleScript is basically what I have been known to say is cool about PHP; its a big spool &#8230; <a href="http://zzot.net/2004/04/17/beautiful/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.apple.com/applescript/">AppleScript</a> — maybe you&#8217;ve heard of it.  In fact, if you&#8217;re
reading my website, you&#8217;ve probably heard of it. What&#8217;s cool about AppleScript
is basically what I have been known to say is cool about PHP; its a big spool
of bungie cord and a bag of clip-on ends.  But that&#8217;s entirely beside the point.</p>

<p>This very website is driven by a CMS, and I have a plugin installed that adds
some source code formatting features.  This plugin, unsurprisingly, doesn&#8217;t
know much about AppleScript<sup id="fnref:mac"><a href="#fn:mac" rel="footnote">1</a></sup> — so I added a really simple one myself.  On
my PowerBook, it worked perfectly — on the public webserver, it didn&#8217;t.</p>

<p>The reason why turned out to be fairly simple, but it was one of those “simple
problems” that you can only find the next day and several meals later.  The
code formatting package the plugin is based on is a perl translation of an
existing PHP package, but most of the syntax definitions haven&#8217;t been
translated along with it yet.<sup id="fnref:many"><a href="#fn:many" rel="footnote">2</a></sup>  What&#8217;s more, of the small number of
definitions present, half of them map to lousy search keywords.</p>

<p>That&#8217;s the thing — there are only about 6, one of them is the language the CMS
is implemented in, another is a word that gets used in comments a lot, a third
gets abbreviated to AS. Getting the picture?</p>

<p>So, to make a long story infinitesimally shorter, I picked one of the
remaining definitions to find all the right places that my new syntax had to
be registered in order to get used. By some strange coincidence, the <em>C#</em>
binding (a.k.a., “csharp”), which I used as an example, was the newest of the
lot, and itself wasn&#8217;t registered in all the right places, given the way I
use everything.</p>

<p>So, by copying the registration details from one <em>non-functional</em> syntax, as
if by magic, my new syntax was also non-functional.  Yay!</p>

<p>Someday soon, when I&#8217;m feeling less cynical, there will be another <em>Cookbook</em>
entry on this, with more technical details, probably including my lame syntax
definition, and connected to the upstream source so this all gets fixed.</p>

<div class="footnotes">
<hr />
<ol>

<li id="fn:mac">
<p>Hey, its cool, but how many people have the good sense to own a Mac?&#160;<a href="#fnref:mac" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:many">
<p>Don&#8217;t get me wrong, there are an awful lot of them.&#160;<a href="#fnref:many" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://zzot.net/2004/04/17/beautiful/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BBEdit Text•Shift Right Script</title>
		<link>http://zzot.net/2003/09/22/bbedit_textshif/</link>
		<comments>http://zzot.net/2003/09/22/bbedit_textshif/#comments</comments>
		<pubDate>Mon, 22 Sep 2003 15:08:18 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[AppleScript]]></category>
		<category><![CDATA[BBEdit]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://zzot.net/wp/2003/09/22/bbedit-textshift-right-script/</guid>
		<description><![CDATA[This is an AppleScript that I used with BBEdit to make the text-indent commands behave the way I expected. It has two known defects: When multiple lines are selected, they don&#8217;t stay that way Errors get thrown in end-of-document cases &#8230; <a href="http://zzot.net/2003/09/22/bbedit_textshif/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is an AppleScript that I used with BBEdit to make the text-indent
commands behave the way I expected. It has two known defects:</p>

<ul>
<li>When multiple lines are selected, they don&#8217;t stay that way</li>
<li>Errors get thrown in end-of-document cases</li>
</ul>

<p>Beyond that, you&#8217;re on your own.</p>

<pre><code>on menuselect(menuName, itemName)
    return false
end menuselect

on postmenuselect(menuName, itemName)
    tell application "BBEdit"
        tell text window 1
            select insertion point before last character of selection
        end tell
    end tell
end postmenuselect
</code></pre>

<p>{: lang=applescript }</p>
]]></content:encoded>
			<wfw:commentRss>http://zzot.net/2003/09/22/bbedit_textshif/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: zzot.net @ 2012-02-06 02:06:38 by W3 Total Cache -->
