Skip to content

Instantly share code, notes, and snippets.

@wallentx
Created October 15, 2015 19:59
Show Gist options
  • Save wallentx/d8e5545559a5698a7728 to your computer and use it in GitHub Desktop.
Save wallentx/d8e5545559a5698a7728 to your computer and use it in GitHub Desktop.
Network indicator for lemonbar
network() {
eth0=$(cat /sys/class/net/eth0/carrier 2>/dev/null)
wlan0=$(cat /sys/class/net/wlan0/carrier 2>/dev/null)
vpn=$(cat /sys/class/net/ppp0/carrier 2>/dev/null)
if [[ $vpn -eq 1 ]]; then
echo -e '\uf084'
ping -W 1 -c 1 8.8.8.8 >/dev/null 2>&1 && echo -e '\uf00c ' || echo -e '\uf00d'
elif [[ $eth0 -eq 1 ]] && [[ $vpn -ne 1 ]]; then
echo -e '\uf0ac'
ping -W 1 -c 1 8.8.8.8 >/dev/null 2>&1 && echo -e '\uf00c ' || echo -e '\uf00d'
elif [[ $wlan0 -eq 1 ]] && [[ $vpn -ne 1 ]] && [[ $eth0 -ne 1 ]]; then
echo -e '\uf1eb'
ping -W 1 -c 1 8.8.8.8 >/dev/null 2>&1 && echo -e '\uf00c ' || echo -e '\uf00d'
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment