first Version
This commit is contained in:
commit
0c4bef47e8
149 changed files with 32273 additions and 0 deletions
40
scripts/network.sh
Executable file
40
scripts/network.sh
Executable file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/bash
|
||||
|
||||
ethernet() {
|
||||
name="Wired"
|
||||
image="ethernet"
|
||||
}
|
||||
|
||||
wifi() {
|
||||
wifiInfo=$(nmcli -t -f active,ssid,signal device wifi list)
|
||||
|
||||
signalStrength=$(awk -F: '/yes:/ {print $3}' <<< $wifiInfo)
|
||||
name=$(awk -F: '/yes:/ {print $2}' <<< $wifiInfo)
|
||||
|
||||
if [[ $signalStrength>=70 ]]; then
|
||||
image="wifiHigh"
|
||||
elif [[ $signalStrength>=60 ]]; then
|
||||
image="wifiMedium"
|
||||
elif [[ $signalStrength>=40 ]]; then
|
||||
image="wifiLow"
|
||||
else
|
||||
image="wifiVeryLow"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
name="No Connection"
|
||||
image="n.A."
|
||||
|
||||
networkInfo=$(nmcli -f NAME,TYPE connection show --active | awk '!/loopback/ && NR > 1')
|
||||
|
||||
if [[ $(awk '/wifi/' <<< $networkInfo) ]]; then
|
||||
wifi
|
||||
fi
|
||||
|
||||
if [[ $(awk '/ethernet/' <<< $networkInfo) ]]; then
|
||||
ethernet
|
||||
fi
|
||||
|
||||
|
||||
echo '{"name":"'$name'","image":"'$image'"}'
|
Loading…
Add table
Add a link
Reference in a new issue