Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status bar shows "null" most of the time. #1

Open
wuweituzi opened this issue Feb 12, 2021 · 1 comment
Open

Status bar shows "null" most of the time. #1

wuweituzi opened this issue Feb 12, 2021 · 1 comment

Comments

@wuweituzi
Copy link

I have everything configured correctly on my linux system. On some days, the status bar shows the correct values but on most days it shows "null" for all variables.

From my .tmux.conf:

set -g @plugin 'odedlaz/tmux-status-variables'
set -g @ipinfo_format "\
📍 #ip \
(#city, #region #country) \
🏭 #isp "

What's breaking here?

@winstonmyers
Copy link

winstonmyers commented Nov 17, 2021

I was having this same issue, and it seems due to hitting the daily limit for the unauthenticated API, here's the ouput with set +x enabled:

++++ get_isp '{ "status": 429, "error": { "title": "Rate limit exceeded", "message": "You'\''ve hit the daily limit for the unauthenticated API. Create an API access token by signing up to get 50k req/month." } }'

I've got a fix for this that sets the $ipinfo="" and enables a sleep timer that waits until the next day to begin running again, using the Plugin Skeleton described in the README.

Here are my current changes within ./tmux-status-variables/scripts/ipinfo.tmux, with line numbers and git gutters:

   17 on_cache_miss() {
   18    log "ipinfo" "getting fresh data from ipinfo.io"
   19    data="$(curl -s ipinfo.io/json)"
   20    log "ipinfo" "$data"
   21
   22    ipinfo=$ipinfo_format
   23    for field in ${fields[@]}; do
   24       get_field_fn="get_$field"
   25
   26       if declare -f $get_field_fn > /dev/null; then
   27          value=$($get_field_fn "$data")
   28       else
   29          value=$(echo $data | jq -r .$field)
   30       fi
   31
   32       ipinfo=${ipinfo/\#$field/$value}
   33    done
   34
~  35    if [ "$ipinfo" != *"null"* ]; then
+  36       echo $ipinfo
+  37       sleep 5m
+  38    else
+  39       ipinfo=""
+  40       echo "$ipinfo"
+  41       sleep "$(($(date -d 23:59:59 +%s) - $(date +%s) + 1))s"
+  42    fi
   43 }

@odedlaz would this be a viable fix for the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants