about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--sh/snippets22
1 files changed, 14 insertions, 8 deletions
diff --git a/sh/snippets b/sh/snippets
index 6f336c1..f82ab7e 100644
--- a/sh/snippets
+++ b/sh/snippets
@@ -54,14 +54,20 @@ EOF
 cd "$HOME/.bitmonero" || exit
 monero-blockchain-export --output-file "$XDG_DOWNLOAD_DIR/xmr/monero_blockchain.raw"
 
-nm_device_state="$(nmcli -t --fields device,state device)"
-if echo "$nm_device_state" | grep -q '^wg_ka:connected$'; then
-	echo ka
-elif echo "$nm_device_state" | grep -q '^wg_studio:connected$'; then
-	echo studio
-else
-	echo insp
-fi
+# the old way, slower and more code
+#nm_device_state="$(nmcli -t --fields device,state device)"
+#if echo "$nm_device_state" | grep -q '^wg_ka:connected$'; then
+#       echo ka
+#elif echo "$nm_device_state" | grep -q '^wg_studio:connected$'; then
+#       echo studio
+#else
+#       echo insp
+#fi
+case "$(nmcli -t --fields device,state device)" in
+	*wg_ka:connected*) echo ka;;
+	*wg_studio:connected*) echo studio;;
+	*) echo insp;;
+esac
 printf 'default: '; curl -m1 ifconfig.co
 printf '4: '; curl -4m1 ifconfig.co
 printf '6: '; curl -6m1 ifconfig.co