It’s unseasonably warm for Christmas here in Minnesota. It’s 50° out. To mark the weird occasion, I created a quick plugin for SearchLink that lets you run a search like:

!current 55987

And get:

Weather for Winona, Minnesota on 2023-12-25 at 12:53 PM: 51.8 and Light rain

The plugin only outputs ‘embed’ style, it won’t provide a URL for your forecast. It’s just meant to inject actual weather data in your writing.

You can input a zip code or city name and region/state and it will give you the current conditions for that location.

There’s also a version that gives you the hourly forecast for the current day as Markdown table:

!forecast winona, mn

Forecast for Winona, Minnesota on 2023-12-25: Moderate rain 53.7/48.7
Currently: 51.8 and Light rain

8am 10am 12pm 2pm 4pm 6pm 8pm
Overcast Patchy rain possible Light rain Light drizzle Light rain Light rain Light rain
49.1 51.0 51.8 52.0 51.8 51.2 50.8

This uses code from Journal, and isn’t meant to be overly detailed or comprehensive, just an easy way to include the current weather in whatever you happen to be writing. Silly, I know, but I already had most of the code.

To use the plugin, grab the weather.rb file from the GitHub SearchLink Plugins repo and place it in ~/.local/searchlink/plugins/weather.rb. Then you’ll need an API key from https://weatherapi.com. Just sign up for a free account and go to https://www.weatherapi.com/my/. You’ll see your API key at the top. Add that to your ~/.searchlink config file like so:

weather_api_key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
weather_temp_in: f

Note the weather_temp_in: setting, which can be ‘c’ or ‘f’ to get your temps in your local format. Then just run !current or !weather searches using a zip/city name as the search terms. Enjoy!

The search type can be shortened to 3-4 characters, e.g. !current can just be !cur and !forecast can just be !for or !fore. !weather and !wea also work for current conditions.

This is just another example of how extensible SearchLink is. If you’re interested in creating your own plugins for any kind of search, it’s pretty easy! By the way, I added a couple new classes, Curl::Html and Curl::Json which make it super easy to retrive an HTML or JSON response from a given URL and extract tags/title/data from them. And the SL.ddg() method makes doing Google/DuckDuckGo searches a one-line affair, so anything you want to search for, the tools are there! If you have any questions about using any of these (or about SearchLink in general) feel free to ask them in the forums!