summaryrefslogtreecommitdiff
path: root/scripts/.local/bin/sb-internet
blob: 6d808521dedd9eedca35a36bee3681c0f65498b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/sh

# Show wifi W and percent strength or w if none.
# Show E if connected to ethernet or e if none.
# Show V if a vpn connection is active

if grep -xq 'up' /sys/class/net/w*/operstate 2>/dev/null ; then
    wifiicon="$(awk '/^\s*w/ { print "W" int($3 * 100 / 70) }' /proc/net/wireless)"
elif grep -xq 'down' /sys/class/net/w*/operstate 2>/dev/null ; then
    grep -xq '0x1003' /sys/class/net/w*/flags && wifiicon="w" || wifiicon="w"
fi

printf "%s%s%s\n" "$(sed "s/.*/V/" /sys/class/net/tun*/operstate 2>/dev/null)" "$(sed "s/down/e/;s/up/E/" /sys/class/net/e*/operstate 2>/dev/null)" "$wifiicon"