There is a new utility on my GitHub page, air-quality.el. It’s a status indicator for the Emacs modeline.
I wanted a way to glance at how the air quality in my area changes through out the day without constantly checking the web, hence the library. I might use this to help determine the best times to take a break and go for a walk during the day.
Installation and configuration is pretty simple. You can install it straight from Github using Straight (or similar tool). Once you have the code, set your latitude and longitude, and your OpenWeather API key. If you do not set this information in your init.el, Emacs will prompt you for it1.
Here is my installation incantation.
(use-package air-quality :straight (:host github :repo "jthaman/air-quality") :init (setq air-quality-open-weather-api-key "<your API key>") (setq air-quality-latitude 38) ; for example (setq air-quality-longitude -77) ; for example :config (air-quality-mode))
The API key is free, and the rate limit is far greater than what is needed to show air quality info in Emacs.
You can configure how often the mode line information is updated, but the default is every hour.
Air quality statistics are a bit unstandardized: there are many systems and scales, and some systems depend on your country. My air-quality.el library just uses the basic categorizations from the OpenWeather API. OpenWeather determines if the quality is “Good” or “Fair”, etc. and I place that information in the modeline. These categorizations are slightly different than the air quality information that comes in the weather app on my iPhone, but I have not yet determined how to do the conversion from the OpenWeather scale to the “US” scale in the iPhone app.
This was a fun project, and I received some good code feedback from the Emacs Help mailing list. The code is more-or-less fine now, but I would like to add some additional features. Most importantly, I’d like to track the data from the API to create a dashboard of air quality information for the previous week. Secondly, the OpenWeather API has some some forecast information about air quality for the next 24 hours. It would be nice to put that in the mode line indicator as well.
That’s a nice tweak that was suggested to me from Emacs Help.↩︎