How To

15th February
2009

Windows-L for the Mac.

written by Mark Wheadon

The need

Coming to Mac OS X from Windows (XP and Vista), I missed being able to lock my session using a simple key-chord. I work in a shared office so it’s sensible to lock the session every time I walk away — something I do regularly.

In Windows, you simply press Windows-L and that’s it — time to go. Mac OS X Leopard doesn’t provide anything as succinct as standard, but there are ways.

Firstly, there are a couple of solutions that are accepted as standard ways of doing this — but unfortunately both have problems. I’ll cover these methods first in case they work for you, and then I’ll cover a solution that really is as quick and easy to use as the Windows’ lock screen key chord.

Partial solution number one: use a hot corner

A hot corner allows you to drop into the screen saver by moving the cursor to a chosen corner of the screen. To do this, first go to System Preferences->Desktop & Screen Saver and click on Hot Corners… Then select Start Screen Saver for one of the corners:

hot-corner-screensaverNow, when you place the cursor in that corner (I chose the bottom-left), the screen saver will start.

Of course, this doesn’t help unless your system is configured to require a password when woken from the screen saver. You can set that in System Preferences->Security:

require-password

And that’s it. Now, before you walk away from your Mac, just drop the cursor into the bottom-left corner of the screen.

However, there is a problem with this method — at least for me — as I don’t want the system to prompt for a password on wakeup. I end up typing my password far too often — every time I’ve left the machine alone long enough for the screen saver to start.

What I want is the Mac to remain unlocked until I explicitly lock it. So, on to solution two…

Partial solution number two: select a pull-down from the menu bar

Here’s another way of locking the machine, and this one doesn’t require that you tick Require password to wake up this computer from sleep or screen saver.

The trick is to enable fast user switching in System Preferences->Accounts->Login Options:

enable-fast-user-switching

which will then place your user name in the menu bar at the top of the screen.

When you want to lock the session, just click on your user name:login-window-from-userand select Login Window… and you’re done. (You can also achieve a similar result by ticking Show Status in Menu Bar in Keychain‘s preferences if you prefer.)

What’s my beef with this solution? The problem is that it’s still rather slow and fiddly — and it’s something I do regularly, so I want to just press and go, just as I did with Windows.

A full solution

To implement a full Windows-L style solution we need Dockables to provide us with an application that locks the Mac OS session, and Quicksilver to launch that application.

First, download and install Dockables from cocoaapp.com. This gives you a bunch of useful applications in a sub-folder of your Applications folder:

dockables

and the one we’re interested in is Lock Screen.

exit-quicksilver-windowNext, download and install Blacktree’s Quicksilver and run it to configure a new Lock Screen key-chord. Quicksilver will present you with its main window — just quit that and instead move to Quicksilver’s menu bar at the top of the screen and select Triggers… from the drop-down menu.

quicksilver-triggers

In the Triggers window that appears, click on the + at the bottom and select HotKey.

add-hotkey

A new window will appear. Click on the first field and start to type lock screen. Quicksilver will rapidly find the Lock Screen dockable you installed earlier. Click Save.

type-lock-screen

Nearly there

You now have a new command, but with no trigger. So click on the None in your new command,

click-on-noneclick in the input field labelled Hot Key: and press the key combination you wish to use to lock your session from now on. (I chose alt+cmd+L because the obvious choice — cmd+L — is already used by Thunderbird — my email client.)

press-hotkeys-copy

I suggest you don’t use the ctrl key as part of your hot key-chord. If you do then quicksilver presents this dialog every time you type the chord:

press-run

Now, having typed a key-chord (which doesn’t include ctrl), exit the Triggers window and you have yourself a new Lock Screen hot key-chord: alt+cmd+L in the example above.

And finally, tweak some settings

You need quicksilver to run at all times, so bring up Quicksilver’s preferences (available from the Quicksilver menu in the menu bar at the top of the screen):

quicksilver-start-at-loginand tick Start at login. You may also want to tidy up the dock a little — as quicksilver is running all the time I’d rather it didn’t appear in the dock and instead appeared in the menu bar:

alt+cmd+Lso I untick Show icon in dock (and I also tick the option check for updates):

quicksilver-full-prefsAnd that’s everything sorted. Any time you need your display locked, just type alt+cmd+L…

cmd+alt+L

and walk away…

8th February
2009

How to change the default application for al files of a given type in Mac OS X.

written by Mark Wheadon

Under Mac OS X, you can easily open a file using something other than the default application by right clicking on the file (cmd+click) and selecting Open With. So, for example, to open a particular text file with MacVim I can do

open-with-for-1-file

And indeed, if I use the Other… option at the bottom of the above menu, I can change the default application for that file. (Although in practice I use an easier way.)

However, that’s only the default application for that one file changed — all other files of the same type will continue to open with the original default application.

To set the default application for all files of that kind (in this example, .txt files), you need to open the Get Info dialogue by right-clicking on the file (or typing alt+cmd I):

get-file-infoopen-with-for-all-filesNow set the application in the file’s info window and click on the Change All… button, confirm by clicking Continue and you’re done. From now on, all files of this kind will be opened with your chosen application.

3rd February
2009

Bless you.

written by Mark Wheadon

SneezeIt’s official

I have the cure. And it’s simple.

Stay away from small children — small children and babies, they’re the worst. Stay away from babies and small children, and large children as well.

And adults. Stay away from them all. Stand in a field with your arms spread and avoid all contact. You may feel like death, you may even wish for death.

But you won’t die of the common cold.

 

 

 

Image courtesy of Brian “DoctaBu” Moore.

31st January
2009

The quick, physical way to hibernate your MacBook.

written by Mark Wheadon

When you close your MacBook’s lid, the machine sleeps. But you’ve probably noticed that it still uses power in its sleep — about 20% of the battery per day, so after about five days it’s flat.

What you may not know is that you can put the MacBook into a much deeper state, where the machine uses almost no power at all. A full battery will then last for months rather than days — useful if you know you’re not going to use your MacBook for a while.

Now, you could install freeware to put your MacBook into this deep-sleep state (often call hibernation) and indeed I have, and it’s good: Deep Sleep. But for the hell of it, here’s a physical way of doing the same, with no additional software required.

Hibernating your MacBook

Check it’s safe to do so

First, close your MacBook’s lid. The illuminated Apple logo on the lid will extinguish almost immediately, but we’re not looking at that.

Look at the light on the front:

MacBook Pro front litIt will eventually start pulsing (breathing 🙂 in its sleep). If that happens almost immediately then sorry, but your MacBook is probably too old for this to work (it hasn’t copied its state to disk), so please don’t carry out the rest of these instructions — you may cause damage.

If, on the other hand, it takes tens of seconds before the light goes from solid-on to pulsing (typically twenty seconds or so) then your MacBook is recent enough for this to work, and you’re ready for the next step.

Let the fun commence

If the power light is now happily pulsing and it took a while to get to that state (whilst the MacBook copied its state to disk) then its time to interrupt the power.

Flip your MacBook over and press the battery-bay latch:

MacBook Pro front unlatchThen remove the cover:

MacBook Pro front cover offand remove the battery, just for a couple of seconds:

MacBook Pro front battery outThen put it all back together and hey-presto, the power light is off and its consuming almost no power at all.

MacBook Pro front not litWhen you next wish to use your MacBook, just open it up and press the power button. (Because it’s off off — really off — you do need to press the power button; opening the lid or pressing a key isn’t enough.) Mac OS X will begin to boot and then show a progress marker while the system’s state is restored from disk:

MacBook Pro unhibernate

After a short while (about 35 seconds on my late-2008 MacBook Pro with 4GB of RAM), your MacBook will spring back to life in the same state as it was when you closed the lid, and with the same battery life!

How’s this work?

Modern Macs do what Windows Vista (for example) calls a Hybrid Sleep whereby it saves its state to disk as well as maintaining the same state using battery power. When you close the lid, the illuminated Apple logo goes off immediately so that you know it’s going to sleep, but actually the MacBook spends the next 20 seconds or so copying its state (mostly the contents of its RAM) on to disk. This is so that, should the battery go flat (and it will do within days, even if it’s full to start with), you won’t lose any data — you just have to wait longer for the machine to wake up once power is restored.

The MacBook then enters a light sleep (usually called standby) whereby the MacBook’s state is preserved by maintaining power to the machine’s RAM, and it’s that power feed that drains the battery.

When you pull the power for a moment, the machine no longer has any live state to preserve and so is essentially off and pulling no power. When you eventually switch it on again, Mac OS X restores its state from the hard drive and everything’s back as it was. It just takes a little longer, that’s all.

Caveats

Here are some things you need to consider before indulging in any of above:

  • You can’t do this on older MacBooks (the clue is in how long the power light takes to reach the sleeping state (pulsing on and off) — if it’s near instant then hybrid sleep isn’t happening and this isn’t going to work).
  • You must wait until the power light is pulsing before pulling the battery;
  • I suggest you don’t do this over-frequently (for example, every day is probably a bad idea) as the battery contacts may not be designed for such a high level of wear-and-tear. (Are there people who remove their MacBook’s battery every day for years on end? I wouldn’t be at all surprised.)
  • Don’t plug in fresh USB devices whilst the Mac is asleep and then wake it from hibernation, as you may find your Mac is less than happy about it.

The software approach

If you don’t like the thought of removing your battery then not to worry — there are several software solutions that will also do the job, and there’s a good guide to them over at Geek Guides.

23rd January
2009

How to set up an external editor for Thunderbird under Mac OS X.

written by Mark Wheadon

If you use Thunderbird on your Mac then you may wish to use an external editor to compose your email rather than the internal one. In my case I’m a long-time vi user so I find it convenient to drop into vi at times, when the editing starts to get non-trivial.

There’s a plugin for Thunderbird which allows you to do this, but setting it up can be tricky, so I thought I’d document it here.

(more…)

21st January
2009

Synching time from multiple NTP servers in Mac OS X.

written by Mark Wheadon

If you’ve set up your MacBook to set its date and time automatically, then there’s a problem: it can’t necessarily connect to any one server from all networks — if you’re behind a corporate firewall for example then you’ll need to use the local NTP server, but that connection will fail when you’re out and about, or sitting at home.

The answer seems to be undocumented, but you can in fact type more than one host name or IP address into the Set date & time automatically field in the Date & Time settings — separated by spaces.

I have mine set like above, so it picks up my ISP (Zen)’s NTP server when I’m at home, the local NTP server if there is one (they’re usually called ntp0, ntp1 etc. or maybe just ntp), or pool.ntp.org if all else fails.

Next