59 lines
1.2 KiB
Bash
Executable file
59 lines
1.2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#INTERFACE="/sys/class/net/wwan0"
|
|
|
|
ICONFONT=8
|
|
|
|
STATE="$(mmcli -m any | grep 'state:' | tr -d ' ' | cut -d ':' -f 2 | cut -d '%' -f 1)"
|
|
SIGNAL="$(mmcli -m any | grep 'signal quality:' | tr -d ' ' | cut -d ':' -f 2 | cut -d '%' -f 1)"
|
|
CARRIER="$(mmcli -m any | grep 'operator name:' | tr -d ' ' | cut -d ':' -f 2 | cut -d '%' -f 1)"
|
|
|
|
# These are intervals of 16%.
|
|
#CHAR_NOSIGNAL=""
|
|
#CHAR_SIGNAL1=""
|
|
#CHAR_SIGNAL2=""
|
|
#CHAR_SIGNAL3=""
|
|
#CHAR_SIGNAL4=""
|
|
#CHAR_SIGNAL5=""
|
|
|
|
CHAR_NOSIGNAL=""
|
|
CHAR_SIGNAL1=""
|
|
CHAR_SIGNAL2=""
|
|
CHAR_SIGNAL3=""
|
|
CHAR_SIGNAL4=""
|
|
CHAR_SIGNAL5=""
|
|
|
|
#echo $STATE
|
|
#echo $SIGNAL
|
|
#echo $CARRIER
|
|
|
|
printicon() {
|
|
echo -n "%{T$ICONFONT}$1%{T-} "
|
|
#echo -n "$1"
|
|
}
|
|
|
|
if [[ "$STATE" != *"connected"* ]]; then
|
|
#if [[ "$STATE" != "connected on" ]]; then
|
|
#echo "$CHAR_NOSIGNAL N/A"
|
|
printicon $CHAR_NOSIGNAL
|
|
echo "N/A"
|
|
exit 0
|
|
fi
|
|
|
|
# This is ugly
|
|
|
|
if [[ "$SIGNAL" -lt "16" ]]; then
|
|
$CHAR_SIGNAL1
|
|
printicon $CHAR_SIGNAL1
|
|
elif [[ "$SIGNAL" -lt "32" ]]; then
|
|
printicon $CHAR_SIGNAL2
|
|
elif [[ "$SIGNAL" -lt "38" ]]; then
|
|
printicon $CHAR_SIGNAL3
|
|
elif [[ "$SIGNAL" -lt "64" ]]; then
|
|
printicon $CHAR_SIGNAL4
|
|
elif [[ "$SIGNAL" -lt "80" ]]; then
|
|
printicon $CHAR_SIGNAL5
|
|
fi
|
|
|
|
echo "$CARRIER"
|