diff options
author | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2019-10-21 20:19:13 +0100 |
---|---|---|
committer | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2019-10-21 20:19:13 +0100 |
commit | 381ed70027c2a64b239997b4363cc316d56de23a (patch) | |
tree | 12b73aa0892156dbf145b718e6b16ce832c6ec3f /modules | |
parent | bb788dddf67c67d8ccd8f365187fea4d470a5d11 (diff) |
Added internet and network modules
Diffstat (limited to 'modules')
-rwxr-xr-x | modules/internet | 13 | ||||
-rwxr-xr-x | modules/network | 30 |
2 files changed, 43 insertions, 0 deletions
diff --git a/modules/internet b/modules/internet new file mode 100755 index 0000000..136005a --- /dev/null +++ b/modules/internet @@ -0,0 +1,13 @@ +#!/bin/bash + +# Prints out if there is an internet connection + +INTERNET_ICON='' + +get_internet() +{ + echo "$INTERNET_ICON" +} + +get_internet + diff --git a/modules/network b/modules/network new file mode 100755 index 0000000..1507ad6 --- /dev/null +++ b/modules/network @@ -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 + |