Register | Login

Stacking Code

public interface IBlog { string Dump(Stream consciousness); }

OS X Lock

Wednesday, 11 December, 2013 @ 10:00 PM < Adam Boddington
Tags: OS X

When I got my first Mac, a MacBook Air, I typically used it either on its own, or hooked up to a Thunderbolt display with an extended USB keyboard and a Magic Mouse. In either scenario I needed a way to quickly lock it when I walked away from it. The cumulative wisdom on the web indicated putting the machine to sleep was the easiest approach, with the system preferences set to require a password on waking. How to quickly get the Mac to sleep then?

One suggestion was to simply close the lid, but that doesn't work with a Thunderbolt display attached. Another was to use the keyboard shortcut Ctrl-Shift-Eject, but the MacBook Air doesn't have an Eject key, and the alternative Ctrl-Shift-Power didn't exist or wasn't well known at the time. Another suggestion was to bind a five finger gesture to sleep, something that might be awkward with a Magic Mouse and would require a third-party app anyway. Another was to use an active corner, but that could cause problems when running Windows 8 in a virtual machine (an OS with a fixation on corners).

The simplest suggestion I could find, and the one I ultimately went with, was to use the screen saver instead of sleep. It too can require a password on exit and is relatively easy to bind to a terminal shortcut. Here's how.

  1. Edit your .bash_profile by typing vim ~/.bash_profile in the terminal.
  2. Add alias ss="/System/Library/Frameworks/ScreenSaver.framework/Resources/" to the bottom of the file (its Vim, so hit G to get to the bottom, o to create a new line, type the line above, then hit Escape).
  3. Type :wq to write the file and quit.

Now when I want to walk away from my Mac, regardless of the peripherals attached, I tab into terminal and type ss and Enter. Instant screen saver, followed by sleep ten minutes later. Exiting either mode requires a password, and that works for me.

There are 0 comments.


Leave a Comment

Please register or login to leave a comment.

HACT '13

Codility Nitrogenium Challenge

HACT '13

Codility Nitrogenium Challenge

browse with Pivot



Building Neno

Recent Posts

Codility Nitrogenium Challenge
OS X Lock
HACT '13
Codility Challenges
Priority Queue


Architecture (13)
Brisbane Flood (1)
Building Neno (38)
C# (4)
Challenges (3)
Collections (1)
Communicator (1)
Concurrency Control (2)
Configuration (1)
CSS (5)
DataAnnotations (2)
Database (1)
DotNetOpenAuth (2)
Entity Framework (1)
FluentNHibernate (2)
Inversion of Control (5)
JavaScript (1)
jQuery (4)
Kata (2)
Linq (7)
Markdown (4)
Mercurial (5)
NHibernate (20)
Ninject (2)
OpenID (3)
OS X (1)
Pivot (6)
PowerShell (8)
Prettify (2)
RSS (1)
Spring (3)
SQL Server (5)
T-SQL (2)
Validation (2)
Vim (1)
Visual Studio (2)
Windows Forms (3)
Windows Service (1)


Powered by Neno, ASP.NET MVC, NHibernate, and small furry mammals. Copyright 2010 - 2011 Adam Boddington.
Version 1.0 Alpha (d9e7e4b68c07), Build Date Sunday, 30 January, 2011 @ 11:37 AM