Ping plugin
This commit is contained in:
parent
5535270397
commit
41d32c0af3
3 changed files with 51 additions and 1 deletions
11
INSTALL.md
11
INSTALL.md
|
@ -48,7 +48,7 @@ To enable plugins set up the `@dracula-plugins` option in you `.tmux.conf` file,
|
|||
The order that you define the plugins will be the order on the status bar left to right.
|
||||
|
||||
```bash
|
||||
# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, network, network-bandwidth, weather, time
|
||||
# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, network, network-bandwidth, network-ping, weather, time
|
||||
set -g @dracula-plugins "cpu-usage gpu-usage ram-usage"
|
||||
```
|
||||
|
||||
|
@ -144,6 +144,15 @@ Customize label
|
|||
set -g @dracula-ram-usage-label "RAM"
|
||||
```
|
||||
|
||||
#### network-ping options
|
||||
|
||||
You can configure which server (hostname, IP) you want to ping and at which rate (in seconds). Default is google.com at every 5 seconds.
|
||||
|
||||
```bash
|
||||
set -g @dracula-ping-server "google.com"
|
||||
set -g @dracula-ping-rate 5
|
||||
```
|
||||
|
||||
#### time options
|
||||
|
||||
Disable timezone
|
||||
|
|
|
@ -163,6 +163,12 @@ main()
|
|||
script="#($current_dir/network_bandwidth.sh)"
|
||||
fi
|
||||
|
||||
if [ $plugin = "network-ping" ]; then
|
||||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-network-ping-colors" "cyan dark_gray")
|
||||
#tmux set-option -g status-right-length 250
|
||||
script="#($current_dir/network_ping.sh)"
|
||||
fi
|
||||
|
||||
if [ $plugin = "weather" ]; then
|
||||
# wait unit $datafile exists just to avoid errors
|
||||
# this should almost never need to wait unless something unexpected occurs
|
||||
|
|
35
scripts/network_ping.sh
Normal file
35
scripts/network_ping.sh
Normal file
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
# configuration
|
||||
# @dracula-ping-server "example.com"
|
||||
# @dracula-ping-rate 5
|
||||
|
||||
current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
ping_function() {
|
||||
case $(uname -s) in
|
||||
Linux | Darwin)
|
||||
# storing the hostname/IP in the variable PINGSERVER, default is google.com
|
||||
pingserver=$(get_tmux_option "@dracula-ping-server" "google.com")
|
||||
pingtime=$(ping -c 1 "$pingserver" | tail -1 | awk '{print $4}' | cut -d '/' -f 2)
|
||||
echo $pingtime
|
||||
;;
|
||||
|
||||
CYGWIN* | MINGW32* | MSYS* | MINGW*)
|
||||
# TODO - windows compatability
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
echo $(ping_function)
|
||||
RATE=$(get_tmux_option "@dracula-ping-rate" 5)
|
||||
sleep $RATE
|
||||
}
|
||||
|
||||
# run main driver
|
||||
main
|
Loading…
Reference in a new issue