adriaandotcom / blog.adriaan.io

The tech blog of Adriaan
https://blog.adriaan.io
Other
10 stars 14 forks source link

turn-off-wifi-when-mac-goes-to-sleep #24

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Turn off Wi-Fi when macOS goes to sleep · Adriaan's blog

https://blog.adriaan.io/turn-off-wifi-when-mac-goes-to-sleep.html

lectricas commented 2 years ago

/usr/local/sbin/sleepwatcher no such file or directory error.

lectricas commented 2 years ago

If I do this sleepwatcher --verbose --sleep ~/Developer/scripts/sleepscript.sh --wakeup /path/to/your/wakeupscript, the sleepwatcher app runs in terminal, but nothing happens.

Can you please describe the effects of each command?

Blackspell01 commented 1 year ago

hey, im really grateful for this noob friendly tutorial. Could you please tell me how I can create a script to turn the wifi back on when Im waking my Mac?

adriaandotcom commented 1 year ago

@Blackspell01 probably with a file at --wakeup /path/to/your/wakeupscript with this as its contents: networksetup -setairportpower Wi-Fi on. Didn't test it though.

bojaman commented 9 months ago

hello, thank you for all information. I installed sleepwatcher 2.2.1. after installation, I received the following message:

For SleepWatcher to work, you will need to write sleep and wakeup scripts, located here when using brew services:

~/.sleep ~/.wakeup

To start sleepwatcher now and restart at login: brew services start sleepwatcher Or, if you don't want/need a background service you can just run: /opt/homebrew/opt/sleepwatcher/sbin/sleepwatcher -V -s /Users//.sleep -w /Users//.wakeup

I created .sleep and .wakeup files using vi, and made them executable (as shown above).

I put in .sleep file the following:

!/bin/sh

networksetup -setairportpower Wi-Fi off

I put in .wakeup file the following:

!/bin/sh

networksetup -setairportpower Wi-Fi on

I ran sleepwatcher brew services start sleepwatcher