summaryrefslogtreecommitdiff
path: root/scripts/eth.sh
diff options
context:
space:
mode:
authorjohannst <stoelp@eit.uni-kl.de>2018-02-25 21:27:13 +0100
committerjohannst <stoelp@eit.uni-kl.de>2018-02-25 21:27:13 +0100
commitba480949ccd5f00f9cfdcae15b67ffb895965833 (patch)
treedf70100706b3b2726e3b04074ed0430378af3008 /scripts/eth.sh
parent32cff6de87dbc18a10c73f5514ae61181c120756 (diff)
downloaddotfiles-ba480949ccd5f00f9cfdcae15b67ffb895965833.tar.gz
dotfiles-ba480949ccd5f00f9cfdcae15b67ffb895965833.zip
moved to i3-gaps and i3blocks
Diffstat (limited to 'scripts/eth.sh')
-rwxr-xr-xscripts/eth.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/scripts/eth.sh b/scripts/eth.sh
new file mode 100755
index 0000000..2fb8b30
--- /dev/null
+++ b/scripts/eth.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+# dotfiles -- scripts/eth.sh
+# author: johannst
+
+if="${BLOCK_INSTANCE:-enp0s25}"
+[[ ! -d /sys/class/net/${if} ]] && exit 0
+
+# operstate: down, up
+[[ "$(cat /sys/class/net/$IF/operstate)" = 'down' ]] && exit 0
+
+# first ipv4 addr
+IP_ADDR=$(ip address show $if | grep 'inet ' | sed 's/\s\+inet \([0-9.]\+\)\/.*/\1/')
+
+echo "$IP_ADDR"
+