weather4bar 1.0.1

Creator: bradpython12

Last updated:

Add to Cart

Description:

weather4bar 1.0.1

weather4bar — Weather for your status bar

What
This is a Python script that shows weather info for the current location.
It's useful for putting into your window manager bar, or just for calling it
from your terminal.


Why
I wrote this because I simply could not find anything else that did the job 100%
right. The internet is full of shell scripts that curl the weather page of
AccuWeather, or a similar service, and manually parse out the HTML file to get
the needed values, most don't even autodetect your location and they make you
pass command-line arguments or set variables for your latitude and longitude,
or, even worse, manually edit the shell script to put those in.


How
This Python script uses the requests library
to create HTTP requests, first, to IP-API, to get IP
geolocation data, and then to Open-Meteo,to get the
weather information.
Then, it parses the data in a nice way, with icons and formatting, and it can be
used either as a script to get weather in your terminal, or be put inside of
Waybar as a custom module.
Right now, I only made formatting for a Waybar tooltip as it's the only bar I've
used yet.


Usage


Help (click to expand)
$ weather4bar --help
usage: weather4bar [-h] [-o {stdout,waybar}] [-t {celsius,fahrenheit}] [-w {kmh,ms,mph,kn}] [-p {mm,inch}] [-T {iso8601,unixtime}]

options:
-h, --help show this help message and exit
-o {stdout,waybar}, --output {stdout,waybar}
Output made for stdout or for parsing by Waybar
-t {celsius,fahrenheit}, --temp-unit {celsius,fahrenheit}
Change the unit used for temperature
-w {kmh,ms,mph,kn}, --wind-unit {kmh,ms,mph,kn}
Change the unit used for wind speed
-p {mm,inch}, --precipitation-unit {mm,inch}
Change the unit used for precipitation
-T {iso8601,unixtime}, --time-unit {iso8601,unixtime}
Change the unit used for time



To get weather in your terminal, simply use:
$ weather4bar

17.6°C
Nowhere

Slight rain
Feels like 19.4°C

If you want to use this in Waybar, you need to create a custom module. You can
look at my dotfiles for an example:

Waybar config file
Waybar style.css file



Packages

NixOS
A derivation for this package is available inside
my Nix package collection.
Just follow
my-nixpkgs/Usage
to add the flake to your config and to add the program to your
environment.systemPackages.
Right now I'm the only person actually using this program, so it's only
available in the repo with my personal Nix derivations. If there's going to be
any interest in it, I'll upstream a derivation into Nixpkgs.
Feel free to just take out the derivation from the
pkgs/ folder and
stick it in your configuration, if you know what you're doing.


PyPi
This script is available in PyPi here.
To install it using pip, run:
$ pip install weather4bar




About the flake
The Nix flake present in this repo is just the development shell I use to test
this script.


More info

Open-Meteo API documentation
IP-API API documentation

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files:

Customer Reviews

There are no reviews.