diff options
| author | Alec Goncharow <algo@cloudflare.com> | 2022-02-20 11:50:35 -0500 |
|---|---|---|
| committer | Alec Goncharow <algo@cloudflare.com> | 2022-02-20 11:50:35 -0500 |
| commit | f5abca7278f3ac0c7358e6f30db8a15da45a1e3b (patch) | |
| tree | 96889e1a2cc2367b8461414ae7c94d9050b84890 /.config/rofi/applets/menu/network.sh | |
| parent | 3e0c8208ccbead65cd434fe730223a7ab854c377 (diff) | |
| parent | 72cf398a6292fa56d57e82caa4d21570e5573294 (diff) | |
Merge branch 'desktop' of github.com:AlecGoncharow/dotfiles into desktop
Diffstat (limited to '.config/rofi/applets/menu/network.sh')
| -rwxr-xr-x | .config/rofi/applets/menu/network.sh | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/.config/rofi/applets/menu/network.sh b/.config/rofi/applets/menu/network.sh new file mode 100755 index 0000000..6e50332 --- /dev/null +++ b/.config/rofi/applets/menu/network.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash + +## Author : Aditya Shakya +## Mail : adi1090x@gmail.com +## Github : @adi1090x +## Twitter : @adi1090x + +style="$($HOME/.config/rofi/applets/menu/style.sh)" + +dir="$HOME/.config/rofi/applets/menu/configs/$style" +rofi_command="rofi -theme $dir/network.rasi" + +## Get info +IFACE="$(nmcli | grep -i interface | awk '/interface/ {print $2}')" +#SSID="$(iwgetid -r)" +#LIP="$(nmcli | grep -i server | awk '/server/ {print $2}')" +#PIP="$(dig +short myip.opendns.com @resolver1.opendns.com )" +STATUS="$(nmcli radio wifi)" + +active="" +urgent="" + +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 + if [[ $STATUS == *"enable"* ]]; then + if [[ $IFACE == e* ]]; then + connected="" + else + connected="" + fi + active="-a 0" + SSID=" $(iwgetid -r)" + PIP="$(wget --timeout=30 http://ipinfo.io/ip -qO -)" + fi +else + urgent="-u 0" + SSID="Disconnected" + PIP="Not Available" + connected="" +fi + +## Icons +bmon="" +launch_cli="" +launch="" + +options="$connected\n$bmon\n$launch_cli\n$launch" + +## Main +chosen="$(echo -e "$options" | $rofi_command -p "$SSID : $PIP" -dmenu $active $urgent -selected-row 1)" +case $chosen in + $connected) + if [[ $STATUS == *"enable"* ]]; then + nmcli radio wifi off + else + nmcli radio wifi on + fi + ;; + $bmon) + termite -e bmon + ;; + $launch_cli) + termite -e nmtui + ;; + $launch) + nm-connection-editor + ;; +esac + |
