aboutsummaryrefslogtreecommitdiff
path: root/home/.config/i3/status/wireless
blob: b113ea4822f4a2d70a065f64639cb7b1651c00aa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
set -o errexit

interface="${BLOCK_INSTANCE:-wlp4s0}"

[[ -d /sys/class/net/$interface/wireless ]] || exit 0

if [[ $(cat "/sys/class/net/$interface/operstate") = "down" ]]; then
    echo OFF
    echo OFF
else
    quality="$(grep "$interface" /proc/net/wireless | \
    			      awk '{ print int($3 * 100 / 70) }')"
    echo "$quality%" # full text
    echo "$quality%" # short text
fi
exit 0