Sponsored by:

Be a Good Mac Laptop Guest

I frequently use my wife’s Macbook because it always seems to be handy when my own laptop is in the other room. I gave myself a user account on the machine, but she started complaining that I’d often forget to switch back to her user account when I was done.

Being a lazy git, I sought out for a technical solution for this problem. The solution I came up with will automatically switch the active user to one of your choice each time the laptop is put to sleep (the lid is closed):

Step 1: Install SleepWatcher

SleepWatcher is a very simple daemon that adds new wakeup, sleep, and idle event triggers to your mac. At the time of this writing, SleepWatcher 2.0.4 can be downloaded here.

Open the .DMG file and install “sleepwatcher.pkg” then “SleepWatcher Startupitem.pkg”.

Step 2: Install SwitchUser

I have crafted a small command line application called SwitchUser to facilitate easily scriptable fast user switching.

Download and install SwitchUser 1.0.

Usage: switchuser

Step 3: Configure the Event

Open terminal and type the following line:

sudo nano /etc/rc.sleep

This will prompt you for your password. Once that is done, enter the following line at the end of the file:

switchuser 'target_user

Remember to replace target_user with the short user name of the account you would like to switch to. If you don’t know that name, it can be found in /Users/.

To exit the editor, press CTRL + o then CTRL + x.

Step 4: Enjoy!

At this point, you should be able to close the lid of your laptop and the computer will automatically switch to the specified account.

One Response to “Be a Good Mac Laptop Guest”

  1. A Laptop Says:

    Hi there, Just wanted to show some love in here!

Leave a Reply