clopez/gnome-shell-system-monitor-applet — comment on commit 0fab1e9ec1dd57a278ddac2e889ae2ab79cf1145
File:  line 0
By clopez:

Your code is wrong in the sense that *NetworkManager.DeviceState.ACTIVATED* don't means that this device is being used as default route. It only means that the device is activated. And you can have it activated to access only the intranet (VPN) for example.

So you can have multiple devices activated, but only one would be the default route.

You need to find a way to select the device that is being used as default route. I don't know if NM can tell you that...

Anyway my code works out of the box on all Linux boxes and don't introduces new unnecessary dependencies (NM), while yours only will work on those that use network manager to configure their entire networking stack.