aboutsummaryrefslogtreecommitdiffstats
path: root/dwm-statusbar
diff options
context:
space:
mode:
Diffstat (limited to 'dwm-statusbar')
-rwxr-xr-xdwm-statusbar42
1 files changed, 41 insertions, 1 deletions
diff --git a/dwm-statusbar b/dwm-statusbar
index c49b622..677e7f1 100755
--- a/dwm-statusbar
+++ b/dwm-statusbar
@@ -120,6 +120,46 @@ print_cpu_used() {
echo -ne "${colour_neutral}\uE3AF${colour_normal}${cpu_used}%"
}
+print_wifi() {
+ wifi_status=$(ip addr show dev wlan0 | awk 'NR==1 {print $9}')
+
+ if [ "$wifi_status" == "UP" ]; then
+ let wifi_strength="10 * $(cat /proc/net/wireless | awk 'NR==3 {print substr($3, 1, 2)}') / 7%"
+ if [ $wifi_strength -lt 25 ]; then
+ icon_colour=${colour_critical}
+ wifi_colour=${colour_critical}
+ elif [ $wifi_strength -lt 50 ]; then
+ icon_colour=${colour_warning}
+ wifi_colour=${colour_warning}
+ else
+ icon_colour=${colour_neutral}
+ wifi_colour=${colour_normal}
+ fi
+
+ wifi_ip=$(ip addr show dev wlan0 | awk 'NR==3 {print $2}' | sed -r 's/\/.*/, /')
+
+ else
+ icon_colour=${colour_faded}
+ fi
+ #uE0E4
+ echo -ne "${icon_colour}\uE401${wifi_colour}${wifi_ip}${wifi_strength}"
+}
+
+print_eth() {
+ eth_status=$(ip addr show dev enp3s0 | awk 'NR==1 {print $9}')
+
+ if [ "$eth_status" == "UP" ]; then
+ eth_ip=$(ip addr show dev enp3s0 | awk 'NR==3 {print $2}' | sed -r 's/\/.*//')
+ icon_colour=${colour_neutral}
+ eth_colour=${colour_normal}
+ else
+ icon_colour=${colour_faded}
+ eth_colour=${colour_normal}
+ fi
+
+ echo -ne "${icon_colour}\uE0E4${eth_colour}${eth_ip}"
+}
+
while true; do
# get new cpu idle and total usage
eval $(awk '/^cpu /{print "cpu_idle_now=" $5 "; cpu_total_now=" $2+$3+$4+$5 }' /proc/stat)
@@ -128,7 +168,7 @@ while true; do
let cpu_used="100 * ($cpu_interval - ($cpu_idle_now-${cpu_idle_old:-0})) / $cpu_interval"
# Pipe to status bar
- xsetroot -name "$(print_cpu_used)${space}$(print_cpu_temp)${space}$(print_mem_free)${space}$(print_battery)${space}$(print_volume)${space}$(print_time)$(print_date)"
+ xsetroot -name "$(print_eth)${space}$(print_wifi)${space}$(print_cpu_used)${space}$(print_cpu_temp)${space}$(print_mem_free)${space}$(print_battery)${space}$(print_volume)${space}$(print_time)$(print_date)"
# reset old rate
cpu_idle_old=$cpu_idle_now