From 1ffefb63640a1b708f8b9855a4f3425bc0e6caea Mon Sep 17 00:00:00 2001 From: Riyyi Date: Fri, 19 Jan 2018 10:24:32 +0100 Subject: [PATCH] Add wifi and iface i3block --- .scripts/wm/iface.sh | 13 +++++++++++++ .scripts/wm/wifi.sh | 17 +++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 .scripts/wm/iface.sh create mode 100755 .scripts/wm/wifi.sh diff --git a/.scripts/wm/iface.sh b/.scripts/wm/iface.sh new file mode 100755 index 0000000..c231940 --- /dev/null +++ b/.scripts/wm/iface.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +WIRED="${BLOCK_INSTANCE:-eth0}" + +echo "" +echo "" +if [ ! -d /sys/class/net/${WIRED} ] || + [ "$(cat /sys/class/net/$WIRED/operstate)" = 'down' ] || + [ "$(ip a | grep $WIRED | awk '/inet / {print $2}')" = "" ]; then + echo "#676E7D" +else + echo "#FFFFFF" +fi diff --git a/.scripts/wm/wifi.sh b/.scripts/wm/wifi.sh new file mode 100755 index 0000000..45225a2 --- /dev/null +++ b/.scripts/wm/wifi.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +WIRELESS="${BLOCK_INSTANCE:-wlan0}" + +if [ ! -d /sys/class/net/${WIRELESS}/wireless ] || + [ "$(cat /sys/class/net/$WIRELESS/operstate)" = 'down' ]; then + echo "" + echo "" + echo "#676E7D" +else + SSID=$(iw dev $WIRELESS link | awk '/SSID/ { print $2 }') + QUALITY=$(grep $WIRELESS /proc/net/wireless | awk '{ print int($3 * 100 / 70) }') + + echo "$SSID  $QUALITY%" + echo "$ $QUALITY%" + echo "#FFFFFF" +fi