Detect if computer connects to internet (Background)

Hey, is it possible to execute a script automaticly every time the computer connects to internet or changes the wifi network?

Thx for you’re help :slight_smile:

Launchd and the socket key is what you’re looking for. I would advice when you can do the task in Bash, don’t do it in AppleScript because of overhead and slowing down your machine. You will be surprised how many times your script will be executed.