I just found this script, and tried it, but it sets polipo to offline whether I disconnect or connect in NetworkManager. The script tries to detect connection status by IP address, but according to
https://wiki.archlinux.org/index.php/NetworkManager#Network_Services_with_NetworkManager_Dispatcher , the connection status is passed to dispatcher scripts as the second argument, so I modified it to just use that. I also changed IFACE to the first argument according to the same reference. I haven't written dispatcher scripts before, but this version fixes the problem for me.
Use the status argument instead of checking IP address
Thanks! I wasn't aware of the passed connection argument. Good find :)