mirror of
https://github.com/dcarrillo/dotfiles.git
synced 2024-12-22 19:48:01 +00:00
[polybar] Add network signal status
This commit is contained in:
parent
194c9f125a
commit
0e138f5409
@ -69,7 +69,7 @@ font-6 = "Font Awesome 5 Brands-Regular-400:size=32:antialias=true;1"
|
||||
|
||||
modules-left = polywins
|
||||
modules-center = custom_date
|
||||
modules-right = updates cpu_bar memory_bar docker vpn network_usage alsa_bar
|
||||
modules-right = updates cpu_bar memory_bar docker vpn network_status network_usage alsa_bar
|
||||
|
||||
cursor-click = pointer
|
||||
cursor-scroll = ns-resize
|
||||
|
@ -87,6 +87,12 @@ double-click-left = /usr/bin/bash ~/.config/polybar/scripts/nmcli_manager &
|
||||
click-right = /usr/bin/bash ~/.config/polybar/scripts/nmcli_manager &
|
||||
tail = true
|
||||
|
||||
[module/network_status]
|
||||
type = custom/script
|
||||
exec = ~/.config/polybar/scripts/network_status
|
||||
click-left = $TERMINAL_CMD "fping --elapsed --count 100 1.1.1.1"
|
||||
interval = 5
|
||||
|
||||
[module/vpn]
|
||||
type = custom/script
|
||||
exec = ~/.config/polybar/scripts/check_vpn
|
||||
|
35
.config/polybar/scripts/network_status
Executable file
35
.config/polybar/scripts/network_status
Executable file
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
URL=${1:-1.1.1.1}
|
||||
|
||||
output=$(fping --quiet --outage --count=5 "$URL" 2>&1)
|
||||
outage_output=""
|
||||
outage_color="FFFFFF"
|
||||
avg_output=""
|
||||
avg_color="FFFFFF"
|
||||
|
||||
avg=$(echo "$output" | cut -d "," -f 3 | cut -d "=" -f 2 | cut -d "/" -f 2 | cut -d "." -f 1)
|
||||
outage=$(echo "$output" | cut -d "," -f 2 | cut -d "=" -f 2 | tr -d " " | cut -d "." -f 1)
|
||||
|
||||
if [ "$outage" -eq 0 ] || [ -z "$outage" ]; then
|
||||
outage_output=""
|
||||
elif [ "$outage" -lt 30 ]; then
|
||||
outage_color=F5A70A
|
||||
else
|
||||
outage_color=FF0000
|
||||
fi
|
||||
|
||||
if [ -z "$avg" ] || [ "$avg" -gt 60 ]; then
|
||||
avg_color=FF0000
|
||||
elif [ "$avg" -lt 40 ]; then
|
||||
avg_output=""
|
||||
else
|
||||
avg_color=F5A70A
|
||||
fi
|
||||
|
||||
if [ -n "$outage_output" ] || [ -n "$avg_output" ]; then
|
||||
echo "%{F#$outage_color}%{T5}${outage_output}%{F-}%{T-}%{F#$avg_color}%{T5} ${avg_output}%{F-}%{T-}"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user