Show the ping on the touchbar

Does anyone have code to show the ping on the touchbar? This would be helpful for a small experiment I'm doing.

Shell script widget.

thanks, but what code?

/sbin/ping -c 2 | tail -1| awk '{print $4}' | cut -d '/' -f 2
would two two pings on google and return the average

now how do I make it say 'ms' after the number without a space in between?

printf "`/sbin/ping -c 2 | tail -1| awk '{print $4ms}' | cut -d '/' -f 2`ms\n"
should do!

awesome! that works. so does this show the ping for everything im doing right now, or just for
edit: this is awesome :smiley: can you give me code to show the fps too please?

A ping shows connectivity, latency a/o packet loss to a specified IP/domain. Not sure what you are asking for "so does this show the ping for everything im doing right now"?

If you are pinging a domain name, you are also checking DNS resolution to that domain. Doesn't have much to do with "everything you are doing right now". Ping is commonly used to Monitor connectivity to a specified server.


anyone know this?

What app did you want to read frame rate? Might be possible in Quicktime, otherwise FPS seems like it would be application dependent and you have to look if that application offers an API. Not sure what would be required, if its possible, or im just over thinking your inquiry.

1 Like

Apple's quartz debug tools have an option to monitor the display's frame rate, but I don't think it has an API (nor is it scriptable)

So I also don't know of an easy way to show that on the Touch Bar. This here could probably be extended to allow something like that: but you'd need to code Swift to make that work.

1 Like