[Arch] fix network, delete bar_scripts
[dotfiles_afify.git] / .scripts / network.sh
blob0e2d4a2b395e0a9c0cf3192312f7128a3d097b13
1 #!/bin/sh
3 ipv4=$(ip -o route get 8.8.8.8 | sed -e 's/^.* src \([^ ]*\) .*$/\1/')
4 ipv6=$(ip -o route get 2001:4860:4860::8888 | sed -e 's/^.* src \([^ ]*\) .*$/\1/')
5 if [ -z $ipv4]; then
6 ip="\x04$ipv6"
7 dev=$(ip -o route get 2001:4860:4860::8888 | sed -e 's/^.* dev \([^ ]*\) .*$/\1/')
8 else
9 ip="\x03$ipv4"
10 dev=$(ip -o route get 8.8.8.8 | sed -e 's/^.* dev \([^ ]*\) .*$/\1/')
13 if [ $dev = $1 ]; then
14 echo " $ip\x01"
15 elif [ $dev = $2 ]; then
16 ssid=$(iw dev wlp62s0 info | sed -n 's/^.*ssid \([^ ]*\)/\1/p')
17 signal=$(iw dev wlp62s0 link | sed -n 's/^.*signal: \([^ ]*\).*/\1/p')
18 if [ $signal -gt -35 ]; then
19 echo " \x02$ssid (\x03$signal dBm\x02)\x01 : $ip\x01"
20 elif [ $signal -gt -60 ]; then
21 echo " \x02$ssid (\x04$signal dBm\x02)\x01 : $ip\x01"
22 elif [ $signal -gt -75 ]; then
23 echo " \x02$ssid (\x05$signal dBm\x02)\x01 : $ip\x01"
24 else
25 echo " \x02$ssid (\x06$signal dBm\x02)\x01 : $ip\x01"
27 else
28 echo "\x06Not connected\x01"