Apple - Is it possible to configure Internet Sharing to allow the computer to sleep?
I have experimented with using ControlPlane to achieve what you want. My preliminary result is that it will do what you want.
ControlPlane detects changes to your system called 'evidence sources'. Changes are evaluated with 'rules' which define a change in 'context'. Associated with each context are 'actions'.
One of the 'evidence sources' is a sleep/wake event. So I have configured a rule so that on a sleep event (e.g. you have clicked sleep in the Apple menu), the context 'Sleepy Time' is triggered. And for this context I have used the action 'ToggleInternetSharing' to off.
After clicking on Sleep, I get an alert saying that Internet Sharing is being turned off and after a little while (seems like forever but is probably only 10 or 20 seconds) the Mac goes to sleep.
And I have a second rule so that on a wake event the context 'Waking Up' is triggered and this has the action to set 'ToggleInternetSharing' on.
My Rules and Actions:
Try it!
This is just scratching the surface of what ControlPlane can do.
If you are running Lion,
InternetSharing
is explicitely locking the SystemSleep
.
Have a look at:
strings /usr/libexec/InternetSharing | grep SystemSleep
The output of this command:
DenySystemSleep
is the proof that InternetSharing
is
purposefully blocking the kernel possibility to go to sleep.
There is a simple explanation to this protection:
once InternetSharing
is fired, clients of this Mac may be using it
as a router to access the Internet. A lot of thing may be automatically
running on top of this Internet connexion without any knowledge of the
person in front of the screen.
This connexion should only be broken by the admin of the system who started it and not any automatic system behaviour.
This is a safe behaviour.
Hence the correct method to ensure InternetSharing
is off when the Mac
sleep is to schedule 4 events in the following order:
InternetSharing off
system sleep
system wakeup
InternetSharing on
This is the scheduling offered by ControlPlane
.