Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions scripts/network-public-ip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,27 @@
# 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
DATAFILE="/tmp/.dracula-tmux-public-ip-data"
LAST_EXEC_FILE="/tmp/.dracula-tmux-public-ip-last-exec"
INTERVAL=1200

main() {
IP_SERVER="ifconfig.me"
ip=$(curl -s "$IP_SERVER")
local _current_dir _last _now
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
_last=$(cat "$LAST_EXEC_FILE" 2>/dev/null || echo 0)
_now=$(date +%s)

IP_LABEL=$(get_tmux_option "@dracula-network-public-ip-label" "")
echo "$IP_LABEL $ip"
source $current_dir/utils.sh

if (((_now - _last) > INTERVAL)); then
IP_SERVER="ifconfig.me"
ip=$(curl -s "$IP_SERVER")

echo "$(get_tmux_option "@dracula-network-public-ip-label" "")$ip" > "${DATAFILE}"
printf '%s' "$_now" > "${LAST_EXEC_FILE}"
fi

cat "${DATAFILE}"
}

# run the main driver
Expand Down
2 changes: 1 addition & 1 deletion scripts/weather_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# setting the locale, some users have issues with different locales, this forces the correct one
export LC_ALL=en_US.UTF-8

DATAFILE="/tmp/.dracula-tmux-data"
DATAFILE="/tmp/.dracula-tmux-weather-data"
LAST_EXEC_FILE="/tmp/.dracula-tmux-weather-last-exec"
INTERVAL=1200

Expand Down