summaryrefslogtreecommitdiffstats
path: root/.local/bin/conky/getif.sh
diff options
context:
space:
mode:
authorJoe <rrbo@proton.me>2023-02-13 10:46:54 +0100
committerJoe <rrbo@proton.me>2023-02-13 10:46:54 +0100
commit1bf7728606159979e6e48f97f0cae38bf455ccf9 (patch)
tree6993478555e3bf70469c63a6128b957582074031 /.local/bin/conky/getif.sh
parentup (diff)
downloaddotfiles-bsd-1bf7728606159979e6e48f97f0cae38bf455ccf9.tar.gz
dotfiles-bsd-1bf7728606159979e6e48f97f0cae38bf455ccf9.tar.bz2
dotfiles-bsd-1bf7728606159979e6e48f97f0cae38bf455ccf9.tar.xz
dotfiles-bsd-1bf7728606159979e6e48f97f0cae38bf455ccf9.tar.zst
dotfiles-bsd-1bf7728606159979e6e48f97f0cae38bf455ccf9.zip
up
Diffstat (limited to '.local/bin/conky/getif.sh')
-rwxr-xr-x.local/bin/conky/getif.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/.local/bin/conky/getif.sh b/.local/bin/conky/getif.sh
new file mode 100755
index 0000000..78a02ef
--- /dev/null
+++ b/.local/bin/conky/getif.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+os=$(cat "/tmp/os")
+
+# ifconfig | command grep '^[a-z]' | awk '{print $1}' | sed '{/lo/d;s/://;}'
+
+case $os in
+ 1)
+ if_main="eth1"
+ if_alt="eth0"
+ ;;
+ 2)
+ if_main="enx4ce1734c425a"
+ if_alt="wlp1s0"
+ ;;
+ 3)
+ if_main="em0"
+ if_alt="wlan0"
+ exit
+ ;;
+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
+ echo '${font1}NETWORK ${hr}${font}
+${color #928374}No network${font}'
+ exit
+fi
+
+echo -n $if_main