Skip to main content

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:

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

Metadata

Release files for weather4bar 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for weather4bar 1.0.2
File Size Uploaded Provenance
weather4bar-1.0.2.tar.gz 12.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for weather4bar 1.0.2
File Interpreter ABI Platform
weather4bar-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 25.8 kB

Release files / weather4bar-1.0.2.tar.gz

Download URL weather4bar-1.0.2.tar.gz
Size 12.9 kB
Tags Source
SHA-256 checksum
How to use checksums
20db4ef8c05360c1a60c8408a92c9b7aabc183af750a0c51bf0c443c018457d0
BLAKE2b-256 checksum
How to use checksums
9b00780637617a1f7302deb01e332a04b3a7fbf4c577928ecbe311b865772998
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.5

Release files / weather4bar-1.0.2-py3-none-any.whl

Download URL weather4bar-1.0.2-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e556b803253b545f3218e7a2a0c47a2759d5f051485bbe8b884f4af9b037aa3a
BLAKE2b-256 checksum
How to use checksums
3d245ebcc9aeaa88ec796f1a691404779eeee5b1970aa09464740231c6e9f31f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.5

Security for weather4bar 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page