Check the internet Connection and display it in the Touch Bar



Am I connected to the Wifi or to the Internet?
My Internet Provider is somewhat unstable, depending on the daytime. So I created this little Apple Script that checks if I'm only connected to my wifi, or if I also get an outgoing connection by pingin in an widget. I didn't want it to repeat continuously, so if you just tap the button the script runs too and returns the result.
Here's the code, the Caliguvara preset itself contains just the one BTT widget:

repeat with i from 1 to 2
		do shell script "ping -o -t 2"
		exit repeat
	on error
		return "🚫"
		delay 2
		return "Error after delay 5"
		if i = 2 then error number -128
	end try
end repeat
return "✅"

Caliguvara.bttpreset (2.3 KB)