dracula / tmux

🧛🏻‍♂️ Dark theme for tmux
https://draculatheme.com/tmux
MIT License
645 stars 295 forks source link

Coordination showing when location set to false Bug #267

Open Edvid opened 4 months ago

Edvid commented 4 months ago

Describe the bug

Sometimes, the weather part of the plugin displays my coordinates, despite having set -g @dracula-show-location falsse

To Reproduce

Steps to reproduce the behavior:

  1. use set -g @dracula-plugins "hostname window cpu-usage gpu-usage ram-usage time weather" or anything else using weather
  2. set -g @dracula-show-location false
  3. Go throughout your day using tmux (It is rare. I have seen it happen three times, and I've been using tmux for half a year)
  4. See behaviour similar to mine

Expected behavior

For this to never ever happen

Screenshots

Excuse the weird blur.. I just didn't want to doxx myself coords

System

Edvid commented 4 months ago

Done a little digging. You make use of an API at wttr.in with curl. The following line dictates how you display temperature in the (sub)plugin. temperature=$(echo $weather_information | rev | cut -d ' ' -f 1 | rev) # +31°C, -3°F, etc This takes the last word of the stdout from the fetch_weather_information() which in turn is the stdout of a curl call to wttr.in with format parameters %C and %t The line is: curl -sL wttr.in/${fixedlocation// /%20}\?format="%C+%t$display_weather". 26th in weather.sh

Sadly, sometimes the output from this API is: Unknown location; please try ~ with being replaced with coordinates

$ curl -SL wttr.in/~Eifal+Tuwer\?format="%C+%t&u"
Unknown location; please try ~not found

$ curl -SL wttr.in/~Eifel+Tower\?format="%C+%t&u"
Unknown location; please try ~49.9456277,6.5562824

$ curl -SL wttr.in/~49.9456277,6.5562824\?format="%C+%t&u"
Unknown location; please try ~49.9457915,6.5566064

$ curl -SL wttr.in/~49.9457915,6.5566064\?format="%C+%t&u"
Unknown location; please try ~49.9457915,6.5566064

This seems to not be an issue with how this plugin parses the input coordinates to the API. The fact that it breaks sometimes seemingly out of nowhere, and the following returned text from curl if we parse no format parameters gives me the impression that this is just their service being down sometimes.

the returned text from API without params:

Sorry, we are running out of queries to the weather service at the moment.
Here is the weather report for the default city (just to show you what it looks like).
We will get new queries as soon as possible.
You can follow https://twitter.com/igor_chubin for the updates.
======================================================================================