diff options
author | mohammadrostamiorg | 2023-12-18 14:05:37 +0330 |
---|---|---|
committer | mohammadrostamiorg | 2023-12-18 14:05:37 +0330 |
commit | a7cd9d59a087fc851c03b5611382cb99af8f83be (patch) | |
tree | 796f086e0f0da0898d2cb012c4c8ba29aef5b9b4 | |
download | aur-pingpong.tar.gz |
first commit
-rw-r--r-- | .SRCINFO | 12 | ||||
-rw-r--r-- | PKGBUILD | 20 | ||||
-rwxr-xr-x | pingpong.sh | 20 |
3 files changed, 52 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..0797019a5511 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,12 @@ +pkgbase = pingpong + pkgdesc = Show internet connection status by ping + pkgver = 1.0 + pkgrel = 1 + arch = any + license = GPL + depends = bash + depends = coreutils + source = pingpong.sh + sha256sums = SKIP + +pkgname = pingpong diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..283030159787 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,20 @@ +# This is an example PKGBUILD file. Use this as a start to creating your own, +# and remove these comments. For more information, see 'man PKGBUILD'. +# NOTE: Please fill out the license field for your package! If it is unknown, +# then please put 'unknown'. + +# Maintainer: Your Name <youremail@domain.com> +pkgname=pingpong +pkgver=1.0 +pkgrel=1 +pkgdesc="Show internet connection status by ping" +arch=('any') +license=('GPL') +maintainer="Mohammad Rosstami <mohammad.jayant@gmail.com>" +source=("pingpong.sh") +depends=('bash' 'coreutils') +pkgrel=1 +sha256sums=('SKIP') +package() { + install -Dm755 pingpong.sh "${pkgdir}/usr/bin/pingpong" +}
\ No newline at end of file diff --git a/pingpong.sh b/pingpong.sh new file mode 100755 index 000000000000..c8caf871bf61 --- /dev/null +++ b/pingpong.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +while true; do + # Use the ping command to check the response time + response_time=$(ping -c 1 8.8.8.8 | grep "time=" | cut -d' ' -f7 | cut -d'=' -f2) + + if [ -z "$response_time" ]; then + # If response_time is empty, it means a timeout occurred + echo "💩💩💩💩💩 Internet Outages" + elif (( $(echo "$response_time > 150" | bc -l) )); then + # If response_time is greater than 100 ms, print "Bad connection" message + echo "🔴🔴🔴🔴🔴 Bad connection: ${response_time} ms" + else + # If response_time is less than or equal to 100 ms, print "Normal connection" message + echo "🟢🟢🟢🟢🟢 Normal connection: ${response_time} ms" + fi + + # Sleep for 5 seconds before the next iteration + sleep 5 +done |