mirror of
https://git.adityakumar.xyz/dwmbar.git
synced 2024-11-22 02:22:53 +00:00
Added internet and network modules
This commit is contained in:
parent
bb788dddf6
commit
381ed70027
2 changed files with 43 additions and 0 deletions
13
modules/internet
Executable file
13
modules/internet
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Prints out if there is an internet connection
|
||||
|
||||
INTERNET_ICON=''
|
||||
|
||||
get_internet()
|
||||
{
|
||||
echo "$INTERNET_ICON"
|
||||
}
|
||||
|
||||
get_internet
|
||||
|
30
modules/network
Executable file
30
modules/network
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Gets the network status
|
||||
|
||||
WIFI_FULL_ICON=''
|
||||
WIFI_MID_ICON=''
|
||||
WIFI_LOW_ICON=''
|
||||
ETHERNET_ICON=''
|
||||
|
||||
get_network()
|
||||
{
|
||||
if grep -q wlan* "/proc/net/wireless"; then
|
||||
# Wifi quality percentage
|
||||
percentage=$(grep "^\s*w" /proc/net/wireless | awk '{ print "", int($3 * 100 / 70)}'| xargs)
|
||||
case $percentage in
|
||||
100|9[0-9]|8[0-9]|7[0-9]) echo "$WIFI_FULL_ICON" ;;
|
||||
6[0-9]|5[0-9]|4[0-9]|3[0-9]) echo "$WIFI_MID_ICON" ;;
|
||||
2[0-9]|1[0-9]|[0-9]) echo "$WIFI_LOW_ICON" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ -d /sys/class/net/eth? ]; then
|
||||
if [ "$(cat /sys/class/net/eth?/carrier)" == "1" ]; then
|
||||
echo "$ETHERNET_ICON"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
get_network
|
||||
|
Loading…
Reference in a new issue