diff options
author | Joe <rrbo@proton.me> | 2023-02-03 12:11:19 +0100 |
---|---|---|
committer | Joe <rrbo@proton.me> | 2023-02-03 12:11:19 +0100 |
commit | 50f86a382ea7188c4768064c631d27ecb02e2ac8 (patch) | |
tree | b9241208382b83fa7bd734d7c800ae303ed9ab34 | |
parent | works for now (diff) | |
download | dotfiles-bsd-50f86a382ea7188c4768064c631d27ecb02e2ac8.tar.gz dotfiles-bsd-50f86a382ea7188c4768064c631d27ecb02e2ac8.tar.bz2 dotfiles-bsd-50f86a382ea7188c4768064c631d27ecb02e2ac8.tar.xz dotfiles-bsd-50f86a382ea7188c4768064c631d27ecb02e2ac8.tar.zst dotfiles-bsd-50f86a382ea7188c4768064c631d27ecb02e2ac8.zip |
up
-rwxr-xr-x | .local/bin/conky/net.sh | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/.local/bin/conky/net.sh b/.local/bin/conky/net.sh index 2e23708..6e6c838 100755 --- a/.local/bin/conky/net.sh +++ b/.local/bin/conky/net.sh @@ -3,7 +3,9 @@ os="$(uname)" tmpfile="/tmp/os" -if ! [ -e "/tmp/os" ]; then +if [ -e "/tmp/os" ]; then + os=$(cat $tmpfile) +else if [ "$os" = "Linux" ]; then grep "Artix" /etc/issue >/dev/null 2>&1 && os=1 || os=2 elif [ "$os" = "FreeBSD" ]; then @@ -13,32 +15,16 @@ if ! [ -e "/tmp/os" ]; then exit 1 fi echo $os >$tmpfile -else - os=$(cat $tmpfile) fi case $os in 1) if_main="eth1" if_alt="eth0" - if grep up "/sys/class/net/$if_main/operstate" >/dev/null 2>&1; then - : - elif grep up "/sys/class/net/$if_alt/operstate" >/dev/null 2>&1; then - if_main=$if_alt - else - exit - fi ;; 2) if_main="enx4ce1734c425a" if_alt="wlp1s0" - if grep up "/sys/class/net/$if_main/operstate" >/dev/null 2>&1; then - : - elif grep up "/sys/class/net/$if_alt/operstate" >/dev/null 2>&1; then - if_main=$if_alt - else - exit - fi ;; 3) if_main="em0" @@ -47,6 +33,14 @@ case $os in ;; esac +if grep up "/sys/class/net/$if_main/operstate" >/dev/null 2>&1 && ! [ -z $(ifconfig $if_main 2>/dev/null | awk '/inet / {print $2}') ]; then + : +elif grep up "/sys/class/net/$if_alt/operstate" >/dev/null 2>&1 && ! [ -z $(ifconfig $if_alt 2>/dev/null | awk '/inet / {print $2}') ]; then + if_main=$if_alt +else + exit +fi + echo '${hr} ${color grey}Interface: ${font1}${color white}'$if_main'${font} ${color grey}--------- |