File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change 33# setting the locale, some users have issues with different locales, this forces the correct one
44export LC_ALL=en_US.UTF-8
55
6- current_dir=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
7- source $current_dir /utils.sh
6+ DATAFILE=" /tmp/.dracula-tmux-public-ip-data"
7+ LAST_EXEC_FILE=" /tmp/.dracula-tmux-public-ip-last-exec"
8+ INTERVAL=1200
89
910main () {
10- IP_SERVER=" ifconfig.me"
11- ip=$( curl -s " $IP_SERVER " )
11+ local _current_dir _last _now
12+ current_dir=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
13+ _last=$( cat " $LAST_EXEC_FILE " 2> /dev/null || echo 0)
14+ _now=$( date +%s)
1215
13- IP_LABEL=$( get_tmux_option " @dracula-network-public-ip-label" " " )
14- echo " $IP_LABEL $ip "
16+ source $current_dir /utils.sh
17+
18+ if (( (_now - _last) > INTERVAL)) ; then
19+ IP_SERVER=" ifconfig.me"
20+ ip=$( curl -s " $IP_SERVER " )
21+
22+ echo " $( get_tmux_option " @dracula-network-public-ip-label" " " ) $ip " > " ${DATAFILE} "
23+ printf ' %s' " $_now " > " ${LAST_EXEC_FILE} "
24+ fi
25+
26+ cat " ${DATAFILE} "
1527}
1628
1729# run the main driver
Original file line number Diff line number Diff line change 22# setting the locale, some users have issues with different locales, this forces the correct one
33export LC_ALL=en_US.UTF-8
44
5- DATAFILE=" /tmp/.dracula-tmux-data"
5+ DATAFILE=" /tmp/.dracula-tmux-weather- data"
66LAST_EXEC_FILE=" /tmp/.dracula-tmux-weather-last-exec"
77INTERVAL=1200
88
You can’t perform that action at this time.
0 commit comments