How to detect network change (unplugging/plugging cable)? I have read at multiple places that the folder /Library/Preferences/SystemConfiguration is supposed to "change" in case that I unplug a network cable.

Now, I have a MacBook Pro, so I use a USB3 adapter to connect a network cable.

Indeed, nothing changes when I plug or unplug it within this folder. I clearly see in "Network settings" that the LAN connection is established or dropped when I plug or unplug the cable.

Where should anything change? Is there some folder or anything else that I can use as trigger for AppleScript, when plugging/unplugging the network cable?
Save this script as an application and set it to run on startup. It will use some memory but the script is very light. You can delay even more. Mind that this routine will keep detecting the cable forever, so you must set other conditions inside your script to do what you need and stop until something changes.



on run {input}
    repeat
        set input to do shell script "ifconfig -a" as text
        set status to offset of "status:" in input
        set the_starting_point to status + 0
        set the_ending_point to status + 13
        set isCableConnected to characters the_starting_point thru the_ending_point of input as string
        if isCableConnected is "status: active" then
            display dialog "Ethernet On"
        else
            display dialog "Cable Unplugged"
        end if
        delay 1
    end repeat
end run