Skip to content

Instantly share code, notes, and snippets.

@camilstaps
Forked from pimeys/wireless.sh
Last active March 2, 2016 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camilstaps/a5999026fc2abcac4cec to your computer and use it in GitHub Desktop.
Save camilstaps/a5999026fc2abcac4cec to your computer and use it in GitHub Desktop.
Wireless plugin for xmobar
#!/bin/bash
INTF=$1
iwconfig "$INTF" 2>&1 | grep -q no\ wireless\ extensions\. && {
echo wired
exit 0
}
essid=`iwconfig "$INTF" | grep 'ESSID:' | cut -d' ' -f 2- | sed 's/^ *//g' | cut -d' ' -f 4- | sed 's/ *$//g'`
essid="${essid:7:(-1)}"
quality=`iwconfig "$INTF" | grep 'Link Quality' | sed 's/^ *//g' | cut -d'=' -f2 | cut -d' ' -f1`
cur=`echo "$quality" | cut -d'/' -f1`
max=`echo "$quality" | cut -d'/' -f2`
bars=$((cur*10/max))
case $bars in
0) bar='[----------]' ;;
1) bar='[#---------]' ;;
2) bar='[##--------]' ;;
3) bar='[###-------]' ;;
4) bar='[####------]' ;;
5) bar='[#####-----]' ;;
6) bar='[######----]' ;;
7) bar='[#######---]' ;;
8) bar='[########--]' ;;
9) bar='[#########-]' ;;
10) bar='[##########]' ;;
*) bar='' ;;
esac
echo "$essid $bar"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment