Crates.io | conditions |
lib.rs | conditions |
version | 0.3.0 |
source | src |
created_at | 2023-09-04 12:35:59.206404 |
updated_at | 2024-01-06 19:10:31.124382 |
description | Fetch basic weather conditions for current or specified location |
homepage | https://github.com/johnallen3d/conditions |
repository | https://github.com/johnallen3d/mp-cli.git |
max_upload_size | |
id | 963125 |
size | 56,647 |
A command line tool for getting the weather conditions at the current location.
* requires an api key
At this time it is necessary to compile and install the crate locally. The simplest way to do this is to install the Rust toolchain.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Then use cargo
to build and install from crates.io
cargo install conditions
By default the Open-Meteo weather provider will be used along with a location determined by the machine's ip address.
> conditions current | jq
{
"temp": 57,
"icon": ""
}
In order to use the Weather API provider create an account and then an API Key. Then persist the api key in settings.
conditions weather-api-key set [your-api-key]
If you prefer to set a specific location you can do so via a postal code:
conditions location set "[postal-code], [country]"
For example:
conditions location set "10001, usa"
Here's how I'm using this with SketchyBar.
#!/bin/bash
conditions="$(conditions current)"
icon=$(echo "$conditions" | jq -r .icon)
temp=$(echo "$conditions" | jq -r .temp)
sketchybar -m \
--set weather_logo icon="${icon}" \
--set weather label="${temp}°F"
Run tasks from this directory via: xc [task-name]
cargo build
cargo build
cargo run
cargo install --path .
Project | Version |
---|---|
rust-lang.org | ^1.6 |
rust-lang.org/cargo | ^0.66 |
git-scm.org | ^2.38 |
xcfile.dev | ^0 |
I wanted to learn rust and had a (cargo-culted) shell script that performed this task for usage with sketchybar.