How I use Quicksilver II: Scripts
Quicksilver is the first program any self-respecting Mac user should install on their box. Instead of giving a general overview of its features (there are already plenty of those), I’m going to prove Quicksilver’s worth by going over exactly how I use it.
This is part two, on scripts.
As I mentioned in the first installment of this bit, I’m going to devote this entire post to explaining how I use scripts with QS. I want to go over some general tricks for employing Quicksilver to run Applescripts and commands as well as discuss some useful QS actions, which are just more complicated scripts that accept inputs from the QS interface.
Useful Trigger Options
Most of the scripts I use are simple Applescripts that I have hotkeyed using standard QS triggers with the “run” action. There are two more advanced trigger options that make these sorts of triggers flashier and easier to use. (Noob note: to view options for a trigger, select it and hit the “i” button in the lower right.)
If the “Show Window” option is on, QS will produce a flashy bezel when this trigger is activated. I’m usually not a fan of stupid eye-candy, but visual feedback is essential for many of these scripts because they perform functions that will run in the background.
I noticed early on that the Show Window bezel displays the icon of the script that its trigger executes. This means that you can identify a script by changing its icon to something relevant to its function. If you’re not sure how to do this, go over this Macinstruct article or use the IconGrabber QS plugin (at the risk of creating a hole in the space-time continuum). I will go over some examples of the Show Window bezel in action to illustrate its practicality.
The second trigger option worth noting is the “Delay:” field, which allows you to specify a time (in seconds) that you will need to hold the trigger’s hotkey before it will activate. This feature safeguards against accidental keypresses and gives the Display Window bezels more screen time.
iTunes Scripts
Quicksilver lets me search through my entire 41 GB music library without ever having to bring iTunes forward. I can play, pause, skip tracks, and shuffle artists, songs, and albums through QS’s interface. I use scripts to accomplish the remaining iTunes tasks I perform with any regularity, so that I can manage my music library almost exclusively through Quicksilver. A key element of this system is Growl, which displays track information in temporary on-screen notifications.
![]()
For Rating Tracks
I use command-option-1 through command-option-5 to set the currently playing song’s rating to a corresponding number of stars. The applescripts to perform this task are included in the iTunes Module plugin:
~/Library/Application Support/Quicksilver/Plugins/iTunes Module.qsplugin/Contents/Resources/Scripts/
I mention the scripts’ location because this is one instance where the Show Display bezel is absolutely necessary. I navigated to the above directory and slapped each of my five rating scripts with an icon that, when it appears in the Show Display bezel, will confirm I’ve just rated the currently playing song a certain number of stars.
![]()
For Displaying Track Information
Because Growl’s song information notification only lingers on my screen for a few seconds and I shuffle often, I’m sometimes left wondering exactly what I am listening to. Luckily, Growl is fully Applescriptable, so I can use a QS trigger to force it to display the currently playing track’s information again. Specifically, I use command-option-? to execute this script (credit to RavenDuck at the Blacktree Forum).
![]()
For Adjusting Volume
Using my function keys for application launching is convenient, but it left me wanting for an easy way to change the system volume. Since OS X doesn’t allow hardware functions to be mapped anywhere outside of F1-F12, I turned to these two scripts. I have them hotkeyed to command-. and command-/, with Display Window on. You’ll notice that the scripts in that archive already have icons to reflect their functions.
![]()
For Tagging Tracks
The last bit of scriptery I use to control music playback is the TuneTag action suite by Chris Brown. The Tag and TagSelected actions allow me to tag my iTunes tracks, and the PlayTag action plays back tracks with a specified tag. All of these actions are accessible entirely from the Quicksilver interface, though the TagSelected action is designed for batch tagging while songs are selected in iTunes.
TuneTag’s tags are just strings in the Comment field preceded by an asterisk, but they offer unlimited control over the organization of my music library. I can do cool things like tag loud, aggressive music with “angry” so I can play it immediately after I’ve been in my Windows partition for a while.
Shell Scripts
I use shell scripts to take care of certain hardware functions. Though Quicksilver can handle shell scripts directly using the Terminal Module plugin, I prefer to pipe the scripts through Applescript with the do shell script command, because then I can assign them icons for use in Display Window bezels.
![]()
For Booting into Windows
I explained this script in a more detailed Macinstruct article, which is a generally good reference if you are interested in more specific information about how to set up scripts for activation via Quicksilver. In short, I use control-B to trigger this script after a two second delay. The script first sets my startup volume to my Windows partition (named “XP” — you must replace this string with your partition’s name if you want the script to work properly) and then restarts my computer.
It’s a true luxury not to have to wait around to hold down the option key during boot to specify my Windows partition, and when I power down Windows after using this script I will boot back into OS X (i.e. the startup volume change is not permanent).
![]()
For Forcing a Time Machine Backup
Time Machine is an optimal backup solution because it requires no user input, but instead runs automatically in the background on a regular schedule. For someone who leaves their Time Machine-stamped external drive plugged in all the time, the regular, scheduled backups work like a charm.
However, I rarely power on my external, and when I do I’d like to be able to tell Time Machine to interrupt its usual schedule and back up my data immediately. Logan Rockmore uncovered a shell script to do exactly this, and it was short work for me to stick it in an Applescript, apply Time Machine’s icon, and create a QS trigger: when I hold command-ctrl-T for two seconds, Time Machine will spring to life.
![]()
For Toggling AirPort Power
I turn my AirPort on and off frequently, depending on my power source and access to ethernet cable. My general aversion to using the mouse for common actions sent me looking for a way to toggle my wireless card’s power with a hotkey. What I turned up was this script, which uses GUI scripting to identify the AirPort menubar item and select its topmost option.
I have no idea where I found the script originally and Google doesn’t have any answers, so I can’t credit it properly. Works like a charm, though.
![]()
For Stripping Text Formatting
Pasting from a website into a rich text document used to drive me nuts. The copied text would drag its hideous font and wacky formatting into whatever I was working on. I ran across a command that strips whatever text is on the clipboard down to plain text by re-copying it:
pbpaste | pbcopy
I skipped the AppleScript and Display Window bezel for this one, opting simply to create a “Run Command in Shell” trigger with pbpaste | pbcopy as the object. I mapped the trigger to control-u, and have already used it to save plenty of time and frustration.
![]()
For Swapping Preferences
There exists a fairly popular piece of shareware called RooSwitch that allows users to shuffle preference files around so they can create multiple user “profiles” for any single application. Though I’m certain RooSwitch is best at what it does, you can achieve its basic functionality by using scripts and Quicksilver, and you can do it for free.
The reason I know this is because USBOverdrive’s application-specific settings don’t work properly in Leopard. I need USBOverdrive to map my mouse buttons to crouch, use medkit, re-arm, and walk so I can properly dominate in the excellent Quake3-based FPS Tremulous. These functions aren’t so useful while I’m cruising around in OS X, so I wrote an Applescript to swap out my global USBOverdrive settings for my Tremulous-specific settings:
do shell script "mv ~/Library/Preferences/com.usboverdrive.mouse.prefs ~/Library/Preferences/com.usboverdrive.1/" do shell script "mv ~/Library/Preferences/com.usboverdrive.2/com.usboverdrive.mouse.prefs ~/Library/Preferences/" do shell script "mv ~/Library/Preferences/com.usboverdrive.1/com.usboverdrive.mouse.prefs ~/Library/Preferences/com.usboverdrive.2/" tell application "USB Overdrive X" to activate tell application "USB Overdrive X" to quit
The script is probably somewhat clumsy because I’m a unix noob, but it gets the job done and you can easily adapt it to any other application’s preferences. It will switch the .plist file in my ~/Library/Preferences folder with a second .plist file in a dummy folder, effectively toggling between global settings and Tremulous settings. I hotkeyed the script to command-option-F9, because command-1-3-3-7 isn’t possible.
Web Scripts
These last few scripts make browsing and interacting with web-based services convenient. I plan to get into a little more detail on how Quicksilver can help you access remote data when I go over plugins in the next, third part of this series.
![]()
For Tweeting
I love Twitter. Now that Twitterriffic is adware, Coda Hale’s Tweet action for Quicksilver is undoubtedly the slickest way to post updates to Twitter. It will accept text input directly from the QS interface and post it to my Twitter feed.
The Tweet action I use is a modification by Joe Carroll that provides length-checking before posting (Twitter will reject Tweets over 140 characters) and Growl notification upon posting. These improvements make the Tweet action’s featureset par with that of Twitter’s web interface, meaning I don’t have to sacrifice functionality for convenience.
Update: Commenter Alex noticed that the script I’ve mirrored above doesn’t work if the tweet’s first character is “@”. His improved version fixes the error, and I’m using it now. Thanks Alex!
![]()
For Shortening URLs
Complex websites can spit out obnoxiously long URLs that are a chore to email or enter in text fields. URL-shortening services like the excellent, bare-bones Metamark use redirection to change obnoxious, long URLs to cute, concise ones like http://xrl.us/bbz66.
Macworld honcho Jason Snell whipped together a handy Applescript that retrieves the URL of Safari’s frontmost page, sends it to Metamark for shortening, and places the new, cute, URL on the clipboard. I have his script hotkeyed to control-I, and use it most often when I am posting a link to Twitter (with the Tweet action, of course!).
![]()
For Navigating Page-Based Sites
Daniel Jalkut of Red Sweater Software has written quite a few useful Applescripts. Amongst them is Safari Next Page, which examines the URL of Safari’s frontmost page to determine if it is one in a series of pages (usually URLs of paged articles and content will have some indicator like page=2). If Safari Next Page recognizes the URL’s format, it will load the next page in the series.
This script is quite useful for navigating websites that enjoy compromising their usability by splitting articles into multiple pages, and I have it mapped to command-right arrow while Safari is the frontmost application.
How to Download YouTube With Safari
I always find it pretty hilarious when whole leagues of software pop up to perform functions most people could accomplish with the programs they already use. Software like this feeds on its own stupidity, because its very existence perpetuates the idea that it has unique features.
A perfect example is the countless applications dedicated to downloading videos from YouTube (and other such flash-based video sites). Some of them even cost money.
It turns out you can use Safari to pull .flv video files from YouTube, and it’s even easy to do. Open any YouTube page in Safari and hit command-option-A (command-option-A) to open Safari’s activity window.
The activity window is a generally useful tool that basically nobody knows about. It is simply a list of all the individual files that make up Safari’s open webpages. If you’re curious about a site’s structure, want to grab a particular image, or just want to know why something is loading slowly, check the activity window.
The activity window will look something like this when a YouTube page is open:
One of these files is not like the others, and that’s the relatively massive (14.7 MB in the above example case) “get_video” .flv video file that you want to download. Select its line in the activity window and copy it (command-C). This puts the .flv’s URL on your clipboard.
Now comes the haxxery. Bring forward Safari’s downloads window (command-option-L) and paste the .flv’s URL (command-V). I’m listing all the keystrokes because they make this little trick very fast.
Wait for your download to complete, and bam! You’ve got the video. However, OS X won’t recognize it as a .flv file quite yet, and that’s because it’s missing a proper file extension. Rename the mystery “get_video” file with a “.flv” at the end.
Now that OS X recognizes the video file, you can play it. I recommend using VLC or Quicktime with Perian.
Update: Rolf points out that it’s possible to save all of the copying and pasting business and cut to the chase by simply double-clicking an item in the activity window while holding the option (alt) key. This action will automatically download the item.
How I Use Quicksilver I: Triggers
I decided to split my authoritative guide to Quicksilver into a few parts, mostly because I know I won’t go to sleep until I have posted something, and it is already 5 AM. Note that this first part won’t include triggers I have set up to run scripts. Those I’ll cover later, in their own part.
Of course, a written series demands an italicized, dramatic, recurring hook:
Quicksilver is the first program any self-respecting Mac user should install on their box. Instead of giving a general overview of its features (there are already plenty of those), I’m going to prove Quicksilver’s worth by going over exactly how I use it.
This is part one, on triggers.
Triggers
QS allows you to hotkey any action as a trigger. If I use a certain action more than three times and I have some free keys to assign it to, I create a trigger.
For Searching
These are the basics — triggers that bring up QS’s interface and ask for a text input.
- Opt-space activates the main QS interface (searches catalogued objects).
- Ctrl-space searches my iTunes collection for specific songs to play or artists, albums, genres, or composers to shuffle.
- Cmd-shift-space searches Google.
- Ctrl-W searches Wikipedia.
- Ctrl-Y searches YouTube.
- Ctrl-M searches MacUpdate.
- Ctrl-F searches IMDb.
For Launching Applications
These triggers will open the specified application — unless the specified application is already open, in which case they will bring its windows to the front.
- F1 activates Safari.
- F2 activates Mail.
- F3 activates iTunes.
- F4 activates my downloads folder in the Finder.
- F5 activates Adium.
- F6 activates Smultron.
- F7 activates MarsEdit.
- F8 activates Skim.
- F9 activates iCal.
- F10 activates Transmit.
- F11 activates System Preferences.
- F12 activates Activity Monitor.
- F13 activates ScreenSaverEngine.1
- F14 activates VMWare Fusion.
Having the applications I use most on my function keys means I use expose sparingly, ⌘⇥ (command-tab) rarely, and the dock literally only when Quicksilver crashes. I’m not joking — look at my dock (hidden by default):
The only reason Activity Monitor makes an appearance is that I occasionally need it to force quit Quicksilver because I run QS as a background application that does not show up in the “Force Quit…” menu.
For Opening Bookmarks
As I’ll get into later, I use Quicksilver to manage my bookmarks. I’ve set these triggers up so they only work when a web browser is the foremost application.
- Cmd-1 opens Facebook.
- Cmd-2 opens del.icio.us.
- Cmd-3 opens Google Reader.
- Cmd-6 opens Sports Illustrated.
- Cmd-7 opens the Best of Craigslist.
Now, let me digress for a minute to mention a great example of the small details that make me appreciate Quicksilver. Safari’s default behavior when a bookmark is opened (by mouse or hotkey) is to load the bookmarked page in the frontmost tab, regardless of what page is already open in that tab. That means that, to open a bookmark in Safari, I would have to first create a new tab so I didn’t lose my current place, and then activate the bookmark. It also means that, once I got a healthy number of tabs going, I would rather create more tabspam than find and select tabs of bookmarked pages that I have already loaded.
Quicksilver’s behavior is much more intelligent than Safari’s. When I use any of the above triggers, QS first checks to see if I already have the specified page open in an existing tab. If I do, it selects that tab and reloads the page. If I don’t, it opens a new tab and loads the specified page.
What this small improvement over Safari’s behavior means is that I save time and my computer runs faster. 15 tabs’ worth of Google Reader make Safari very hungry for RAM.
For Doing Other Useful Things
These are the remaining triggers that don’t qualify as scripts because they call various built-in QS actions.
- Cmd-space makes iTunes play or pause.
- Cmd-; makes iTunes skip to the previous track.
- Cmd-’ makes iTunes skip to the next track.
- Ctrl-E ejects my external drive.
- Ctrl-P copies the selected file(s) to the desktop of my Windows XP partition.
- Ctrl-escape activates the main QS interface with the selected file(s) as object(s).
- Cmd-opt-T activates CharPaletteServer.2
The iTunes triggers give me total control over my music without ever having to see iTunes’ unpleasant Carbon window, and CharPaletteServer is a necessity for dashes of proper length.
The trigger for moving files over to my XP partition is only a small glimpse of what’s possible with proxy objects.
Keep an eye out for part two, on scripts.
-
ScreenSaverEngine runs the screensaver, thereby blacking out and password-protecting my screen. Its location:
/System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app
-
CharPaletteServer serves up special characters and symbols. Its location:
/System/Library/Components/CharacterPalette.component/Contents/SharedSupport/CharPaletteServer.app
Site Redesign
One of the reasons I haven’t posted anything here in quite some time is that I have been coding instead of writing. I was kind of shocked to see that my old design looked like crap in Internet Explorer and I wanted to make some major changes anyway, so I set out to completely overhaul my layout and stylesheet.
I really didn’t have any idea it would be so tricky to put together something that looked cool and worked in an acceptable portion of web browsers. Having no previous experience in CSS or HTML, I worked out one problem at a time by examining the websites of people who know what they are doing, Googling frequently, and, primarily, trial and error. If Stanford looked at my network traffic lately, they’d notice my 4KB stylesheet being uploaded at an obscene frequency.
There are two sections off to the right of the main column now. Under “Linklist” is where I’ll post random, interesting stuff, and under “Tracklist” is what is going on in my iTunes.
I set up the Linklist because I wanted to reserve the main column for my longer, better posts. I set up the Tracklist because I think it’s cool. You’ll notice they both have their own RSS feeds — from here on out, the main feed will only syndicate this main column’s longer posts.
Let me know if there are any bugs in the new design. I’ve validated the CSS and HTML, ran it in Safari, Firefox, and Internet Explorer, and done a few batches on BrowserShots, but my limited experience with web design tells me there must be some errors still lurking out there.


