feat: update linux network ssid fetch

This commit is contained in:
Abhishek Keshri 2023-03-29 14:07:36 +05:30
parent d2491d15a3
commit 3837498239
No known key found for this signature in database
GPG key ID: 62BD6AA2E913B3D3

View file

@ -4,12 +4,11 @@ export LC_ALL=en_US.UTF-8
HOSTS="google.com github.com example.com" HOSTS="google.com github.com example.com"
get_ssid() get_ssid() {
{
# Check OS # Check OS
case $(uname -s) in case $(uname -s) in
Linux) Linux)
SSID=$(iw dev | sed -nr 's/^\t\tssid (.*)/\1/p') SSID=$(iwgetid -r)
if [ -n "$SSID" ]; then if [ -n "$SSID" ]; then
printf '%s' "$SSID" printf '%s' "$SSID"
else else
@ -29,14 +28,13 @@ get_ssid()
# leaving empty - TODO - windows compatability # leaving empty - TODO - windows compatability
;; ;;
*) *) ;;
;;
esac esac
} }
main() main() {
{
network="Offline" network="Offline"
for host in $HOSTS; do for host in $HOSTS; do
if ping -q -c 1 -W 1 "$host" &>/dev/null; then if ping -q -c 1 -W 1 "$host" &>/dev/null; then