Esegui EDITOR=nano crontab -e
e aggiungi una riga come questa:
* * * * * pgrep -qx Safari&&networksetup -setairportpower en0 on||networksetup -setairportpower en0 off
Il comando viene eseguito solo una volta al minuto però.
Puoi anche salvare questo plist come ~ / Library / LaunchAgents / safariwifi.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>safariwifi</string>
<key>ProgramArguments</key>
<array>
<string>bash</string>
<string>-c</string>
<string>while sleep 10;do pgrep -qx Safari&&mode=on||mode=off;[[ $last != $mode ]]&&networksetup -setairportpower en0 $mode;last=$mode;done</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Esegui launchctl load ~/Library/LaunchAgents/safariwifi.plist
.