summaryrefslogtreecommitdiff
path: root/i3/.config/i3blocks/bin
diff options
context:
space:
mode:
Diffstat (limited to 'i3/.config/i3blocks/bin')
-rwxr-xr-xi3/.config/i3blocks/bin/wifi9
1 files changed, 5 insertions, 4 deletions
diff --git a/i3/.config/i3blocks/bin/wifi b/i3/.config/i3blocks/bin/wifi
index bc24672..b545c24 100755
--- a/i3/.config/i3blocks/bin/wifi
+++ b/i3/.config/i3blocks/bin/wifi
@@ -1,15 +1,16 @@
#!/usr/bin/env bash
-quality=$(iwconfig wlp2s0 2>/dev/null | grep -oP 'Link Quality=\K[0-9]*/[0-9]*' | awk -F'/' '{print int(100*$1/$2)}')
-ssid=$(iwconfig wlp2s0 2>/dev/null | grep -oP '(?<=ESSID:").*(?=")')
-wifi_address=$(ip addr show wlp2s0 2>/dev/null | grep -oP -m1 "(?<=inet ).*(?=/)")
+wireless=$(ip link | grep -oP -m1 "(wlp[^:]*)")
+quality=$(iwconfig $wireless 2>/dev/null | grep -oP 'Link Quality=\K[0-9]*/[0-9]*' | awk -F'/' '{print int(100*$1/$2)}')
+ssid=$(iwconfig $wireless 2>/dev/null | grep -oP '(?<=ESSID:")[^\"]*')
+wifi_address=$(ip addr show $wireless 2>/dev/null | grep -oP -m1 "(?<=inet ).*(?=/)")
eth_address=$(ip addr show eno1 2>/dev/null | grep -oP -m1 "(?<=inet ).*(?=/)")
if [[ -n $eth_address ]]; then
full_text="eno1: $eth_address"
ip_addr="$eth_address"
elif [[ -n $wifi_address ]]; then
- full_text="wlp2s0: (${quality}% at ${ssid}) ${wifi_address}"
+ full_text="${wifi_address} (${quality}% at ${ssid})"
ip_addr="$wifi_address"
else
echo "No connection"