Monday, 9 January 2012

Tech

Mac insomnia

For a good year or so my laptop has been suffering from insomnia. Every now and then, for no apparent reason it'll wake itself up. It might be lying undisturbed on the desk, or it might be in the bag on my back. This is not good, especially in the latter case when it typically doesn't fall asleep, but instead runs the battery flat.

You can find out why your Mac wakes up by typing the following command in Terminal:

$ grep "Wake reason" /var/log/kernel.log | last
Jan 5 19:56:53 fowey kernel[0]: Wake reason: EC LID0 FRWR

There'll be one line of output for each time the laptop's awakened recently. The LID0 indicates that it woke because it thought the laptop had been opened.

In my case I think the lid sensor is defunct — perhaps the magnet that activates it has come out of alignment somehow.

Rather than take it in for service, it's possible to disable the "wake-on-lid-open" feature.

First, check that the feature is indeed enabled:

$ pmset -g | grep lidwake
 lidwake        1

The 1 indicates it's enabled; a 0 would indicate disabled.

Now change the setting:

$ sudo pmset -a lidwake 0

The prompt should return without further output, but if you repeat the above check, you should see the setting has taken.

Now opening the lid won't wake the laptop, but key press or mouse move will. Excellent, sleep-enhanced nights all round.

Posted by pab at 11:09 | Comments will be back one day. Please email me instead!