diff --git a/.config/i3blocks/config b/.config/i3blocks/config index e5a6cf8..c5de4ed 100644 --- a/.config/i3blocks/config +++ b/.config/i3blocks/config @@ -64,5 +64,4 @@ interval=30 [wifi] command=i3wifi -instance=wlp2s0 interval=10 diff --git a/.scripts/i3wifi b/.scripts/i3wifi index b9f79ec..178c88e 100755 --- a/.scripts/i3wifi +++ b/.scripts/i3wifi @@ -1,25 +1,9 @@ -#!/bin/bash +#!/bin/sh case $BLOCK_BUTTON in - 1) $TERMINAL -e sudo -A wifi-menu ;; + 1) $TERMINAL -e nmtui ;; esac -INTERFACE="${BLOCK_INSTANCE:-wlan0}" +[ "$(cat /sys/class/net/w*/operstate)" = 'down' ] && echo 📡 && exit -[[ "$(cat /sys/class/net/$INTERFACE/operstate)" = 'down' ]] && echo 📡 && exit - -QUALITY=$(grep $INTERFACE /proc/net/wireless | awk '{ print int($3 * 100 / 70 - 1) }') - -echo 📶 $QUALITY% -echo 📶 $QUALITY% - -# color -if [[ $QUALITY -ge 80 ]]; then - echo "#00FF00" -elif [[ $QUALITY -lt 40 ]]; then - echo "#FF0000" -elif [[ $QUALITY -lt 60 ]]; then - echo "#FF8000" -elif [[ $QUALITY -lt 80 ]]; then - echo "#FFF600" -fi +grep ^w /proc/net/wireless | awk '{ print "📶", int($3 * 100 / 70) "%" }'