aboutsummaryrefslogtreecommitdiff
path: root/Common/rofi/applets/menu/network.sh
diff options
context:
space:
mode:
authorJakob Stendahl <jakob.stendahl@outlook.com>2021-09-04 12:04:53 +0200
committerJakob Stendahl <jakob.stendahl@outlook.com>2021-09-04 12:04:53 +0200
commit65b7f91e51d90e93c3d7c6704c0a8265467a8ea7 (patch)
tree88301071c7f1840b502f33cbd3b0f7c5e81b0c66 /Common/rofi/applets/menu/network.sh
parenta77563ee1044ffa03f7c49e457a5f7c9f943188f (diff)
parente6df7072ab32493a561fc678eacc119b57981827 (diff)
downloaddotfiles-65b7f91e51d90e93c3d7c6704c0a8265467a8ea7.tar.gz
dotfiles-65b7f91e51d90e93c3d7c6704c0a8265467a8ea7.zip
Merge branch 'master' of https://github.com/JakobS1n/dotfiles
Diffstat (limited to 'Common/rofi/applets/menu/network.sh')
-rwxr-xr-xCommon/rofi/applets/menu/network.sh68
1 files changed, 68 insertions, 0 deletions
diff --git a/Common/rofi/applets/menu/network.sh b/Common/rofi/applets/menu/network.sh
new file mode 100755
index 0000000..80c270f
--- /dev/null
+++ b/Common/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)
+ urxvt -e bmon
+ ;;
+ $launch_cli)
+ urxvt -e nmtui
+ ;;
+ $launch)
+ nm-connection-editor
+ ;;
+esac
+