aboutsummaryrefslogtreecommitdiff
path: root/i3/blocks/network
blob: cb06e877f18bae43412101ec91144d2a18969c69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash

device="${BLOCK_INSTANCE:-wlan0}"
status=$(cat /sys/class/net/${device}/operstate)

URGENT_VALUE=20

if [[ "${status}" == "up" ]]; then
  if [[ -d "/sys/class/net/${device}/wireless" ]]; then
    quality=$(grep ${device} /proc/net/wireless | awk '{ print int($3 * 100 / 70) }')
    echo "${quality}%"
    echo "${quality}%"
    echo ""

    if [[ "${quality}" -le "${URGENT_VALUE}" ]]; then
      exit 33
    fi
  else
    echo "on"
    echo "on"
    echo ""
  fi
fi