Toggle Wi Fi during sleep wake up - profzei/Matebook-X-Pro-2018 GitHub Wiki
Depending on the version of AirportItlwm.kext or the macOS release, Wi-Fi may not automatically reconnect to known networks during system wake-up. Toggle off / on Wi-Fi device button makes the trick: but such a solution is very annoying!
For this reason it is possible to automate this procedure using SleepWatcher through Homebrew.
For installing SleepWatcher and its services, please, refer to step #13 and following here.
Here are the additional steps:
- Command line to identify network service order:
/usr/sbin/networksetup -listnetworkserviceorder
- Create a Sleep and Wakeup file in your home directory:
touch ~/.sleep && chmod 755 ~/.sleep
touch ~/.wakeup && chmod 755 ~/.wakeup
- Put the following script into
~/.sleep
to disable the wifi adapter:
#!/bin/bash
/usr/sbin/networksetup setairportpower en1 off
touch /tmp/sleep.log
cat > /tmp/sleep.log
echo "Sleeping: `date`" >> /tmp/sleep.log
echo `/usr/sbin/networksetup getairportpower en1` >> /tmp/sleep.log
- Put the following script into
~/.wakeup
to re-enable the wifi adapter:
#!/bin/bash
sleep 10
/usr/sbin/networksetup setairportpower en1 on
echo "Waking Up: `date`" >> /tmp/sleep.log
echo `/usr/sbin/networksetup getairportpower en1` >> /tmp/sleep.log
- You can see the most recent sleep/wake cycle in the
/tmp/sleep.log
file:
cat /tmp/sleep.log
Note Your Wi-Fi device should be en1
References