1
0
Fork 0
dotfiles/screen/wireless-signal

44 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
#
# Displays wireless signal strength for the given interface
#
# Copyright (C) 2013 Mike Gerwitz
#
# 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 <http://www.gnu.org/licenses/>.
##
iface="$1"
iwconfig "$iface" \
| grep -o 'Link Quality=[^ ]\+' \
| cut -d'=' -f2 \
| awk -F/ '
{
quality = ($1 / $2 * 100);
color = ".";
if ( quality >= 75 )
color = "g";
else if ( quality >= 50 )
color = "y";
else if ( quality < 25 )
{
color = "r";
}
printf "\005{+ .m}%s:\005{-}\005{+ .%c}%d%%\005{-}", \
"'$1'", color, quality;
}
'