I have Debian 10 running on a small SBC (industrialized Raspberry Pi like form factor). I have some python programs running that make use of inotify capabilities. I want to detect when the network status changes so I can toggle a light. Should I look around for some files in something like /sys/class/net/eth1 and watch for a change with notify? and compute a status from whats in that directory somehow? Or is there a better way to do this that doesn't involve polling?
I was trying to infer this from my mqtt client connection status, but that's not responsive enough and at times is ambiguous anyway.
Is there perhaps some hook that systemd/networkd would provide to make this possible?