Prevent a Mac from waking up from keyboard or mouse

keyboardmousesleep-wake

I put my PowerMac at work to sleep so that I can use Wake-on-LAN to do remote work on it. However the office cleaner often touches the keyboard or the mouse button unintentionally. So the question is:

How to disable mouse and keyboard wake up; to just use the power button and wake-on-LAN to wake/sleep instead?

Don't tell me to disconnect mouse and keyboard.

Best Answer

The solution I can offer is to use Sleepwatcher and add the following to your ~/.wakeup script:

#!/bin/bash

WR=`syslog | grep -i "Wake reason =" | tail -1 | awk '{ print $11 }'`

if [[ "$WR" =~ EHC[0-9] ]]; then
    pmset sleepnow
fi

This won't prevent your Mac from waking via keyboard or mouse. It will however sleep the computer immediately after it is woken via keyboard, mouse, or any other USB device.

According to an anonymous user this works for some versions of OS X (e.g. Mavericks):

#!/bin/bash

WR=`syslog | grep -i "Wake reason:" | tail -1 | awk '{ print $11 }'`

if [[ "$WR" =~ EHC[0-9] ]]; then
    pmset sleepnow
fi