Quickly create text files on your desktop for editing

A few days ago a friend of mine approached me with something like this:

“While taking notes in meetings I would like to quickly create a text file on my desktop and open it for editing in my editing application. Any ideas?”

My initial thought was something along the lines of “…there are about a hundred ways of doing that – pick one!”. Problem for my friend was that, only because there are hundreds of ways of doing that, he just needed one that works for him.

Fortunately he is an avid user of Alfred (… and my approach works the same for Quicksilver or any other application launcher).

Here is the basic idea:

  1. Write a shell script that creates a text file on the desktop, with a name that includes the date and time, and open the file in an editor.
  2. Wrap that script in an Automator application
  3. Use the Application launcher to execute that application when needed.

Here is the script:

#!/bin/sh
d=`date +%Y%m%d%H%M%S`
me=`whoami`
filename=’/Users/’$me’/Desktop/untitled_’$d’.txt’
touch $filename
open -a TextWrangler $filename

Since I use TextWrangler as editor for plain text files I used that in the last line of the script. Simply change that to whichever application you prefer.

Next step is to open Automator and create a new document of type “Application”:

Application_Type

Next add a “Run Shell Script” action and  add the script in the text field:

Automator_Window

 

Save the application with whatever name you like (I used “createTXTFile.app”). Now use Alfred or Quicksilver to execute your beautiful new application. Done!

 

Force Quicksilver to index Firefox 3 bookmarks

OK, this one baffled me: One of the quicksilver functionalities I use the most is the opening of URLs.

I recently switched back from Safari to Firefox 3, something I do from time to time just to keep life interesting.

Even though I enabled the Firefox plugin in Quicksilver it didn’t index the Firefox bookmarks, because Firefox 3 stores the bookmarks in a format that Quicksilver can’t read. Fortunately the solution is simple:

First go to the “about:config”-page in your browser bar:

about_config

In the resulting page enter “bookmarks.autoExportHTML” to find the entry for “browser.bookmarks.autoExportHTML”.

bookmarks_settings

Now all you need to do is set the value for this preference to “true”.

From now on Firefox will, every time Firefox quits, write the bookmarks in html format in your preferences folder. Quicksilver will index this file (as long as the Firefox plugin in Quicksilver is enabled). You’re done!

Mute system volume with Apple Script and Quicksilver

Quicksilver’s iTunes plugin comes with several excellent scripts, one of them is to mute iTunes.

The only problem is, that you can still hear all the system sounds. Pretty annoying if you are in a meeting or sitting in a class.

My workaround was to write an Apple Script to control the system volume:

set curVol to (get (output volume of (get volume settings)))
if curVol > 0 then
set volume output volume 0
else
set volume output volume 50
end if

This script will mute the system volume, or set it back to 50% if it’s already muted (the value for “set volume” is a percentage value from 0 to 100).

That’s it, I created a keyboard trigger to execute this script (I used Shift-Ctrl-Command + M) and I can mute my system without having to use the mouse or trackpad.

How to use a Microsoft keyboard with your Mac

Using a Microsoft keyboard with a MacBook is possible but has one major drawback: The “Option” and “Command”-keys are exchanged and called “Windows” and “Alt”-keys.

Fortunately swapping the keys so that the “Command” and “Option”-keys are in the same location like on an Apple keyboard is very simple:

  1. Open your “System Preferences”
  2. Select “Keyboard & Mouse”
  3. Select the “Keyboard”-tab
  4. Click on “Modifier Keys…”

In the resulting dialog map the Option Key to “Command” and vice versa. This is a screenshot made with Tiger, the dialog in Leopard looks a little bit different:

Key Mappings

Voila – that’s it. Now the Microsoft keyboard should behave just like an Apple keyboard.

Now, for one additional problem (if you are still using Tiger or before):

I am using my MacBook Pro in my office, so I’m frequently connecting and disconnecting my keyboard. Since my external keyboard is an ergonomic keyboard with Microsoft keys I would have to change those settings each and every time I connect or disconnect the keyboard. This is only the case if you’re still using Tiger or before, because in Leopard you can set the keys for each keyboard type as shown in this screenshot: Keyboard settings in Leopard

One solution is an AppleScript, which I found on the following website:

Change keyboard modifier keys automatically on OSX with Applescript

Now I have a Quicksilver Trigger to execute this Applescript, which makes the swapping of the “Command” and “Option”-keys quick and painless!

How to create a Quicksilver Trigger

A Quicksilver trigger is a convenient way to define a global shortcut, accessible no matter which application is currently active or the frontmost.

There are two kinds of triggers: Keyboard and Mouse triggers. The mouse trigger is very similar to the keyboard trigger, only that you click a mouse button along with some function keys instead of just a key.

Here is how to create a trigger in Quicksilver to do something very basic, for example launch Apples “Mail” application:

First select “Triggers” from the Quicksilver menu in your toolbar at the top of your screen:

Toolbar Preferences

In the dialog that appears Click on the little plus-sign at the bottom and select “HotKey” for a keyboard trigger or “Mouse” for a mouse trigger. In my example I am selecting “HotKey” for a keyboard trigger:

Create Trigger

Quicksilver will show a dialog very similar to the normal Quicksilver interface. Define the trigger exactly the same way you would ususally use Quicksilver to do something. So in this example I select “Mail” as item and “Open” as the action:

Define Trigger

You should now have a new trigger to open the mail application, so the only thing left is to define which key combination will invoke the trigger. To do that select your new trigger and click the little “i”-button at the bottom right of the dialog:

Open Drawer

A drawer will open with the details of the trigger:

Trigger drawer

Click on the “Edit” button for the hot key. Enter the key combination you would like to use for the trigger.

I always use the combination “Shift-Control-Command” along with a defining key for all my Quicksilver triggers. This key combination may feel odd at first, but it didn’t take long for me to get used to it. The advantage of this combination is that it only very seldom causes any conflict with keyboard shortcuts in other applications.

This concludes the creation of a keyboard trigger. Mouse triggers are created similar, only that the drawer to define the Hot Key looks a bit different to cater for the options you have when using a mouse.