diff --git a/wifi/README.md b/wifi/README.md new file mode 100644 index 00000000..10f9e24c --- /dev/null +++ b/wifi/README.md @@ -0,0 +1,16 @@ +# wifi + +Show the strength of your wifi connection. +If no instance is specified, wlan0 is used. + +![](wifi.png) + +# Config + +``` +[wifi] +command=$SCRIPT_DIR/wifi +label=wifi: +#instance=wlp3s0 +interval=60 +``` diff --git a/wifi/i3blocks.conf b/wifi/i3blocks.conf new file mode 100644 index 00000000..41e81626 --- /dev/null +++ b/wifi/i3blocks.conf @@ -0,0 +1,5 @@ +[wifi] +command=$SCRIPT_DIR/wifi +label=wifi: +#instance=wlp3s0 +interval=60 diff --git a/wifi/wifi b/wifi/wifi new file mode 100755 index 00000000..6fe4d478 --- /dev/null +++ b/wifi/wifi @@ -0,0 +1,46 @@ +#!/bin/bash +# Copyright (C) 2014 Alexander Keller + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +#------------------------------------------------------------------------ + +INTERFACE="${BLOCK_INSTANCE:-wlan0}" + +#------------------------------------------------------------------------ + +# As per #36 -- It is transparent: e.g. if the machine has no battery or wireless +# connection (think desktop), the corresponding block should not be displayed. +[[ ! -d /sys/class/net/${INTERFACE}/wireless ]] || + [[ "$(cat /sys/class/net/$INTERFACE/operstate)" = 'down' ]] && exit + +#------------------------------------------------------------------------ + +QUALITY=$(grep $INTERFACE /proc/net/wireless | awk '{ print int($3 * 100 / 70) }') + +#------------------------------------------------------------------------ + +echo $QUALITY% # full text +echo $QUALITY% # short text + +# color +if [[ $QUALITY -ge 80 ]]; then + echo "#00FF00" +elif [[ $QUALITY -ge 60 ]]; then + echo "#FFF600" +elif [[ $QUALITY -ge 40 ]]; then + echo "#FFAE00" +else + echo "#FF0000" +fi diff --git a/wifi/wifi.png b/wifi/wifi.png new file mode 100644 index 00000000..5549de66 Binary files /dev/null and b/wifi/wifi.png differ