diff options
author | Justine Smithies <justine@smithies.me.uk> | 2024-02-06 20:44:09 +0000 |
---|---|---|
committer | Justine Smithies <justine@smithies.me.uk> | 2024-02-06 20:44:09 +0000 |
commit | e2add462c0d66120867cdb7181a0d9c413f3e4c1 (patch) | |
tree | 4b313161d3300eeb5196d0b49d716cbec2bdc57f /.config/eww/scripts/network.sh | |
parent | 7620f87b79f7e8a4cfb6f672094a138518420d7a (diff) |
Initial commit of Eww config
Diffstat (limited to '.config/eww/scripts/network.sh')
-rwxr-xr-x | .config/eww/scripts/network.sh | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/.config/eww/scripts/network.sh b/.config/eww/scripts/network.sh new file mode 100755 index 0000000..cceebd7 --- /dev/null +++ b/.config/eww/scripts/network.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# This script requires dnsutils aka bind to fetch the WAN IP address + +# Shows the connections names +# nmcli connection show --active | grep 'ethernet' | awk '{ print $1 }' FS=' ' +# nmcli connection show --active | grep 'wifi' | awk '{ print $1 }' FS=' ' + +# Show ethernet interface name +# nmcli connection show --active | grep 'ethernet' | awk '{ print $6 }' FS=' ' + +# Show wifi interface name +# nmcli connection show --active | grep 'wifi' | awk '{ print $4 }' FS=' ' + +function ShowInfo { + if [ "$(nmcli connection show --active | grep -oh "\w*ethernet\w*")" == "ethernet" ]; then + wan="$(dig +short myip.opendns.com @resolver1.opendns.com)" + connection="$(nmcli connection show --active | grep 'ethernet' | awk '{ print $6 }' FS=' '): $(nmcli connection show --active | grep 'ethernet' | awk '{ print $1 }' FS=' ') - $(nmcli -t -f IP4.ADDRESS dev show $(nmcli connection show --active | grep 'ethernet' | awk '{ print $6 }' FS=' ') | awk '{print $2}' FS='[:/]') +WAN IP: $wan" + elif [ "$(nmcli connection show --active | grep -oh "\w*wifi\w*")" == "wifi" ]; then + wan="$(dig +short myip.opendns.com @resolver1.opendns.com)" + connection="$(nmcli connection show --active | grep 'wifi' | awk '{ print $4 }' FS=' '): $(nmcli connection show --active | grep 'wifi' | awk '{ print $1 }' FS=' ') - $(nmcli -t -f IP4.ADDRESS dev show $(nmcli connection show --active | grep 'wifi' | awk '{ print $4 }' FS=' ') | awk '{print $2}' FS='[:/]') +WAN IP: $wan" + else + connection="No active connection." + fi + notify-send -i "network-idle" "$connection" -r 123 +} + +function IconUpdate() { + if [ "$(nmcli connection show --active | grep -oh "\w*ethernet\w*")" == "ethernet" ]; then + icon="" + elif [ "$(nmcli connection show --active | grep -oh "\w*wifi\w*")" == "wifi" ]; then + icon="" + else + icon="" + fi + printf "%s" "$icon" +} + +if [ "$1" = "ShowInfo" ]; then + ShowInfo +else + IconUpdate +fi |