moved all desktop utils into this repo

This commit is contained in:
willifan 2024-06-03 11:56:16 +02:00
parent cd7e93374e
commit 2241d30a86
28 changed files with 151 additions and 45 deletions

43
ewwScripts/network.sh Executable file
View file

@ -0,0 +1,43 @@
#!/usr/bin/env 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 -ge 70 ]]; then
image="wifiHigh"
elif [[ $signalStrength -ge 60 ]]; then
image="wifiMedium"
elif [[ $signalStrength -ge 40 ]]; then
image="wifiLow"
else
image="wifiVeryLow"
fi
}
while true; do
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"'"}'
sleep 2
done