Dotfiles for my tiling window manager + terminal workflow.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.8 KiB

  1. #!/bin/bash
  2. # Copyright (C) 2014 Alexander Keller <github@nycroth.com>
  3. # This program is free software: you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation, either version 3 of the License, or
  6. # (at your option) any later version.
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. # You should have received a copy of the GNU General Public License
  12. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. #------------------------------------------------------------------------
  14. INTERFACE="${BLOCK_INSTANCE:-wlan0}"
  15. # echo $INTERFACE
  16. # INTERFACE="${INSTANCE}"
  17. #------------------------------------------------------------------------
  18. # As per #36 -- It is transparent: e.g. if the machine has no battery or wireless
  19. # connection (think desktop), the corresponding block should not be displayed.
  20. # [[ ! -d /sys/class/net/${INTERFACE}/wireless ]] ||
  21. # [[ "$(cat /sys/class/net/$INTERFACE/operstate)" = 'down' ]] && exit
  22. #------------------------------------------------------------------------
  23. QUALITY=$(sudo grep $INTERFACE /proc/net/wireless | awk '{ print int($3 * 100 / 70) }')
  24. # echo $QUALITY
  25. W_inter=$(ip link | grep "[1-9]: wlp" | cut -d " " -f2 | tr -d ':')
  26. W_name=$(nmcli d | grep "$W_inter" | awk '{print $4}')
  27. #------------------------------------------------------------------------
  28. echo $QUALITY% "$W_name" # full text
  29. echo $QUALITY% # short text
  30. # color
  31. if [[ $QUALITY -ge 80 ]]; then
  32. echo "#00FF00"
  33. elif [[ $QUALITY -lt 80 ]]; then
  34. echo "#FFF600"
  35. elif [[ $QUALITY -lt 60 ]]; then
  36. echo "#FFAE00"
  37. elif [[ $QUALITY -lt 40 ]]; then
  38. echo "#FF0000"
  39. fi