A Python script that shows weather info for the current location.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file weather4bar-1.0.2.tar.gz
.
File metadata
- Download URL: weather4bar-1.0.2.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20db4ef8c05360c1a60c8408a92c9b7aabc183af750a0c51bf0c443c018457d0 |
|
MD5 | cf2a646d903185a5ab81560007d98233 |
|
BLAKE2b-256 | 9b00780637617a1f7302deb01e332a04b3a7fbf4c577928ecbe311b865772998 |
File details
Details for the file weather4bar-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: weather4bar-1.0.2-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e556b803253b545f3218e7a2a0c47a2759d5f051485bbe8b884f4af9b037aa3a |
|
MD5 | 41d2c03d1f69d9c358f7fc2656a03271 |
|
BLAKE2b-256 | 3d245ebcc9aeaa88ec796f1a691404779eeee5b1970aa09464740231c6e9f31f |