tmux-kanagawa/scripts/network.sh

28 lines
583 B
Bash
Raw Normal View History

2020-03-15 22:18:06 +01:00
#/usr/bin/env bash
#author: Dane Williams
#script for gathering internet connectivity info
#script is called in dracula.tmux program
get_ssid()
{
2020-03-16 00:13:08 +01:00
if /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | grep -E ' SSID' | cut -d ':' -f 2 &> /dev/null; then
echo "$(/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | grep -E ' SSID' | cut -d ':' -f 2)"
2020-03-15 22:18:06 +01:00
else
2020-03-16 00:13:08 +01:00
echo ' Ethernet'
2020-03-15 22:18:06 +01:00
fi
}
main()
{
if ping -q -c 1 -W 1 google.com &>/dev/null; then
echo "$(get_ssid)"
else
2020-03-16 00:13:08 +01:00
echo ' Offline'
2020-03-15 22:18:06 +01:00
fi
}
#run main driver function
main