From 79027a519d89774b7a63966d01df2f26ff6d423d Mon Sep 17 00:00:00 2001 From: ljseng Date: Fri, 12 May 2023 00:02:31 +0800 Subject: [PATCH 1/2] add network public ip plugin --- README.md | 2 +- scripts/dracula.sh | 4 ++++ scripts/network-public-ip.sh | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100755 scripts/network-public-ip.sh diff --git a/README.md b/README.md index 630f72e2..8a5406da 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul - Support for powerline - Day, date, time, timezone - Current location based on network with temperature and forecast icon (if available) -- Network connection status, bandwidth and SSID +- Network connection status, bandwidth, SSID and public IP (requires `curl`) - Git branch and status - Battery percentage and AC power connection status - Refresh rate control diff --git a/scripts/dracula.sh b/scripts/dracula.sh index a2bff10b..dde2f74a 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -217,6 +217,10 @@ main() fi fi + elif [ $plugin = "network-public-ip" ]; then + IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-network-public-ip-colors" "cyan dark_gray") + script="#($current_dir/network-public-ip.sh)" + else continue fi diff --git a/scripts/network-public-ip.sh b/scripts/network-public-ip.sh new file mode 100755 index 00000000..ff962347 --- /dev/null +++ b/scripts/network-public-ip.sh @@ -0,0 +1,18 @@ +#!/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 + +current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $current_dir/utils.sh + +main() { + IP_SERVER="ifconfig.me" + ip=$(curl -s "$IP_SERVER") + + IP_LABEL=$(get_tmux_option "@dracula-network-public-ip-label" "") + echo "$IP_LABEL $ip" +} + +# run the main driver +main From 96835e6bb9b93a6fda4c010b4f9e35651ef5e45d Mon Sep 17 00:00:00 2001 From: ljseng Date: Fri, 12 May 2023 01:07:56 +0800 Subject: [PATCH 2/2] Update INSTALL.md Add network-public-ip --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 16fcbbd0..edc6385e 100644 --- a/INSTALL.md +++ b/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, network-ping, attached-clients, network-vpn, weather, time, spotify-tui, kubernetes-context +# available plugins: battery, cpu-usage, git, gpu-usage, ram-usage, network, network-bandwidth, network-ping, network-public-ip, attached-clients, network-vpn, weather, time, spotify-tui, kubernetes-context set -g @dracula-plugins "cpu-usage gpu-usage ram-usage" ```