network (1471B)
1 #!/bin/bash 2 3 STYLE="default" 4 5 rofi_command="rofi -theme $STYLE/network.rasi" 6 7 ## Get info 8 IFACE="$(nmcli | grep -i interface | awk '/interface/ {print $2}')" 9 #SSID="$(iwgetid -r)" 10 #LIP="$(nmcli | grep -i server | awk '/server/ {print $2}')" 11 #PIP="$(dig +short myip.opendns.com @resolver1.opendns.com )" 12 STATUS="$(nmcli radio wifi)" 13 14 active="" 15 urgent="" 16 17 if (ping -c 1 archlinux.org || ping -c 1 google.com || ping -c 1 bitbucket.org || ping -c 1 github.com || ping -c 1 sourceforge.net) &>/dev/null; then 18 if [[ $STATUS == *"enable"* ]]; then 19 if [[ $IFACE == e* ]]; then 20 connected=" Connected To Internet" 21 else 22 connected=" Connected To Internet" 23 fi 24 active="-a 0" 25 SSID="$(iwgetid -r)" 26 PIP="$(wget --timeout=30 http://ipinfo.io/ip -qO -)" 27 fi 28 else 29 urgent="-u 0" 30 SSID="Disconnected" 31 PIP="NA" 32 connected=" Offline" 33 fi 34 35 ## Icons 36 bmon=" Open Bandwidth Monitor" 37 launch_cli=" Open Network Manager" 38 launch=" Open Connection Editor" 39 40 options="$connected\n$bmon\n$launch_cli\n$launch" 41 42 ## Main 43 chosen="$(echo -e "$options" | $rofi_command -p "$SSID : $PIP" -dmenu $active $urgent -selected-row 1)" 44 case $chosen in 45 $connected) 46 if [[ $STATUS == *"enable"* ]]; then 47 nmcli radio wifi off 48 else 49 nmcli radio wifi on 50 fi 51 ;; 52 $bmon) 53 termite -e bmon 54 ;; 55 $launch_cli) 56 termite -e nmtui 57 ;; 58 $launch) 59 nm-connection-editor 60 ;; 61 esac 62