blob: b545c24bb385e5c533b95f8d4ca2a62822652212 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/usr/bin/env bash
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="${wifi_address} (${quality}% at ${ssid})"
ip_addr="$wifi_address"
else
echo "No connection"
fi
case $BLOCK_BUTTON in
1) echo "$full_text" ;;
*) echo -e "$ip_addr" ;;
esac
|