aboutsummaryrefslogtreecommitdiff
path: root/segments/wan_ip.sh
diff options
context:
space:
mode:
authorCody Hiar <codyfh@gmail.com>2017-04-20 19:37:10 -0600
committerCody Hiar <codyfh@gmail.com>2017-04-20 19:37:10 -0600
commit2dd809781527976307b47a598887062047e202c9 (patch)
tree8b29daba2c1ef072f380ef530b7e7d9256e43eb3 /segments/wan_ip.sh
parentbaeb698bb006193559fc5aa1901180a3ccc73b7a (diff)
Making tmux configuration much easier to manage
Diffstat (limited to 'segments/wan_ip.sh')
-rwxr-xr-xsegments/wan_ip.sh43
1 files changed, 0 insertions, 43 deletions
diff --git a/segments/wan_ip.sh b/segments/wan_ip.sh
deleted file mode 100755
index 811d100..0000000
--- a/segments/wan_ip.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-# Prints the WAN IP address. The result is cached and updated according to $update_period.
-
-run_segment() {
- local tmp_file="${TMUX_POWERLINE_DIR_TEMPORARY}/wan_ip.txt"
- local wan_ip
-
- if [ -f "$tmp_file" ]; then
- if shell_is_osx || shell_is_bsd; then
- stat >/dev/null 2>&1 && is_gnu_stat=false || is_gnu_stat=true
- if [ "$is_gnu_stat" == "true" ];then
- last_update=$(stat -c "%Y" ${tmp_file})
- else
- last_update=$(stat -f "%m" ${tmp_file})
- fi
- elif shell_is_linux || [ -z $is_gnu_stat]; then
- last_update=$(stat -c "%Y" ${tmp_file})
- fi
-
- time_now=$(date +%s)
- update_period=900
- up_to_date=$(echo "(${time_now}-${last_update}) < ${update_period}" | bc)
-
- if [ "$up_to_date" -eq 1 ]; then
- wan_ip=$(cat ${tmp_file})
- fi
- fi
-
- if [ -z "$wan_ip" ]; then
- wan_ip=$(curl --max-time 2 -s http://whatismyip.akamai.com/)
-
- if [ "$?" -eq "0" ]; then
- echo "${wan_ip}" > $tmp_file
- elif [ -f "${tmp_file}" ]; then
- wan_ip=$(cat "$tmp_file")
- fi
- fi
-
- if [ -n "$wan_ip" ]; then
- echo "ⓦ ${wan_ip}"
- fi
-
- return 0
-}