obzen
obzen

Reputation: 1

BASH with YAD to display avg ping

I am new to bash and I am trying to ping a host and display the average ping times. I want to auto-update that value in a YAD window. I have it set in while loop, but the problem is that I have to close the window for the new value to repopulate. Can yad achieve such dynamic update?

Thanks

#!/bin/bash

HOSTS="google.com"
COUNT=2

while true
do 
  echo $(yad --title="Latency Monitor" --text="$(ping -c $COUNT $HOSTS 2>&1 | tail -1| awk -F/ '{print $6}' )" --text-align=center --no-buttons --height=50 --width=300)
done

Upvotes: 0

Views: 207

Answers (1)

Scooby-2
Scooby-2

Reputation: 167

I know this is old - but just adding

--timeout 1

at the end of the yad switches will make it auto close after 1 second. So it becomes:

#!/bin/bash

HOSTS="google.com"
COUNT=2

while true
do 
  echo $(yad --title="Latency Monitor" --text="$(ping -c $COUNT $HOSTS 2>&1 | tail -1| awk -F/ '{print $6}' )" --text-align=center --no-buttons --height=50 --width=300 --timeout 1)
done

Upvotes: 0

Related Questions