mirror of
https://github.com/bvanroll/_dotfiles.git
synced 2025-08-29 20:12:42 +00:00
init
This commit is contained in:
24
.config/i3blocks/wlan-dbm/README.md
Normal file
24
.config/i3blocks/wlan-dbm/README.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# wlan-dbm
|
||||
|
||||
Show wifi interface link quality in dBm or percent.
|
||||
|
||||

|
||||
|
||||
# Usage
|
||||
|
||||
The block uses dBm by default, set USE_PERCENT=1 to use percent.
|
||||
Note, however, that percent is just an estimate that may not accurately predict
|
||||
whether you have a good signal.
|
||||
|
||||
# Dependencies
|
||||
|
||||
* `iw`
|
||||
|
||||
# Config
|
||||
|
||||
```INI
|
||||
[wlan-dbm]
|
||||
command=$SCRIPT_DIR/wlan-dbm
|
||||
#IFACE=wlan0
|
||||
#USE_PERCENT=0
|
||||
```
|
53
.config/i3blocks/wlan-dbm/wlan-dbm
Executable file
53
.config/i3blocks/wlan-dbm/wlan-dbm
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# i3blocks blocklet script to display wifi signal in dBm
|
||||
|
||||
if [[ -z "$IFACE" ]] ; then
|
||||
IFACE="${BLOCK_INSTANCE:-wlan0}"
|
||||
fi
|
||||
|
||||
USE_PERCENT=${USE_PERCENT:-0}
|
||||
|
||||
IW=$(which iw || echo "/sbin/iw")
|
||||
|
||||
if [[ ! -x $IW ]]; then
|
||||
echo "No iw binary was found on the system." 1>2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while getopts p opt; do
|
||||
case "$opt" in
|
||||
p) USE_PERCENT=1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
dbm=$($IW dev "$IFACE" link | grep 'dBm$' | grep -Eoe '-[0-9]{2}')
|
||||
|
||||
[[ -n "$dbm" ]] || exit 1
|
||||
|
||||
if [[ $USE_PERCENT -eq 0 ]]; then
|
||||
echo "$dbm" dBm
|
||||
echo "$dbm"
|
||||
else
|
||||
if [[ "$dbm" -le -100 ]]; then
|
||||
quality=0
|
||||
elif [[ $dbm -ge -50 ]]; then
|
||||
quality=100
|
||||
else
|
||||
quality=$((2 * (dbm + 100)))
|
||||
fi
|
||||
echo "$quality%"
|
||||
echo "$quality%"
|
||||
fi
|
||||
|
||||
if [[ $dbm -ge -55 ]]; then
|
||||
echo "#00FF00"
|
||||
elif [[ $dbm -ge -60 ]]; then
|
||||
echo "#CCFF00"
|
||||
elif [[ $dbm -ge -70 ]]; then
|
||||
echo "#FFFF00"
|
||||
elif [[ $dbm -ge -80 ]]; then
|
||||
echo "#FFAA00"
|
||||
else
|
||||
echo "#FF0000"
|
||||
fi
|
BIN
.config/i3blocks/wlan-dbm/wlan-dbm.png
Normal file
BIN
.config/i3blocks/wlan-dbm/wlan-dbm.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 770 B |
Reference in New Issue
Block a user