From 0baf312a0afa1a1b2dec3be1164ccd480b64737a Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Wed, 1 Aug 2018 20:38:48 -0400 Subject: [PATCH] i3wifi added --- .config/i3blocks/config | 13 ++++++------- .scripts/i3wifi | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 7 deletions(-) create mode 100755 .scripts/i3wifi diff --git a/.config/i3blocks/config b/.config/i3blocks/config index 778d0f4..0042ac0 100644 --- a/.config/i3blocks/config +++ b/.config/i3blocks/config @@ -42,12 +42,6 @@ signal=10 [iface] label=🌐 #instance=wlan0 -color=#00FF00 -interval=10 - -[wifi] -label=📶 -instance=wlp2s0 interval=10 [battery] @@ -56,5 +50,10 @@ interval=5 [time] label=📅 -command=echo $(date '+%Y %b %d %I:%M%p') 🕓 +command=echo $(date '+%Y %b %d (%a) %I:%M%p') 🕓 interval=30 + +[wifi] +command=i3wifi +instance=wlp2s0 +interval=10 diff --git a/.scripts/i3wifi b/.scripts/i3wifi new file mode 100755 index 0000000..3fe5fb0 --- /dev/null +++ b/.scripts/i3wifi @@ -0,0 +1,25 @@ +#!/bin/bash + +case $BLOCK_BUTTON in + 1) $TERMINAL -e sudo -A wifi-menu ;; +esac + +INTERFACE="${BLOCK_INSTANCE:-wlan0}" + +[[ "$(cat /sys/class/net/$INTERFACE/operstate)" = 'down' ]] && echo 📡 && exit + +QUALITY=$(grep $INTERFACE /proc/net/wireless | awk '{ print int($3 * 100 / 70) }') + +echo 📶 $QUALITY% +echo 📶 $QUALITY% + +# color +if [[ $QUALITY -ge 80 ]]; then + echo "#00FF00" +elif [[ $QUALITY -lt 80 ]]; then + echo "#FFF600" +elif [[ $QUALITY -lt 60 ]]; then + echo "#FFAE00" +elif [[ $QUALITY -lt 40 ]]; then + echo "#FF0000" +fi