GithubHelp home page GithubHelp logo

bjesus / wttrbar Goto Github PK

View Code? Open in Web Editor NEW
137.0 3.0 24.0 130 KB

Custom module for showing the weather in Waybar, using the great wttr.in

License: MIT License

Rust 100.00%
sway waybar wayland weather wttr

wttrbar's Introduction

wttrbar

a simple but detailed weather indicator for Waybar using wttr.in.


Installation

Compile yourself using cargo build --release, or download the precompiled binary from the releases page.

For Arch Linux, use the AUR package.

For NixOS, use the NixPkg package.

Usage

  • --ampm - display time in AM/PM format
  • --location STRING - pass a specific location to wttr.in
  • --main-indicator - decide which current_conditions key will be shown on waybar. defaults to temp_C
  • --date-format - defaults to %Y-%m-%d, formats the date next to the days. see reference
  • --hide-conditions - show a shorter descrpition next to each hour, like 7° Mist instead of 7° Mist, Overcast 81%, Sunshine 17%, Frost 15%
  • --fahrenheit - use fahrenheit instead of celsius
  • --mph - use mph instead of km/h for wind speed
  • --custom-indicator STRING - optional expression that will be shown instead of main indicator. current_conditions keys surrounded by {} can be used. For example, "{ICON}{temp_C}({FeelsLikeC})" will be transformed to "text":"🌧️0(-4)" in the output
  • --lang LANG - set language (currently en, de, pl, tr, fr, ru, zh, be, es, pt, it, ja, uk, sv; submit a PR to add yours)

e.g. wttrbar --date-format "%m/%d" --location Paris --hide-conditions

Icons

To display the weather icons correctly, you will need to have a font that supports emojis installed. The screenshot uses Noto Emoji, but you can use other fonts too.

Waybar configuration

Assuming wttrbar is in your path, it can be used like:

"custom/weather": {
    "format": "{}°",
    "tooltip": true,
    "interval": 3600,
    "exec": "wttrbar",
    "return-type": "json"
},

Old version

This code is based on my old Python gist that was used for the same purpose.

wttrbar's People

Contributors

3eldu avatar bjesus avatar bluewydiamond avatar bowlbird avatar celticboozer avatar dianaw353 avatar edvind avatar frai3mega avatar gmarconi avatar gwichiad avatar haikuno avatar khaneliman avatar kleyeus avatar lvntcnylmz avatar nut-3 avatar puddings233 avatar s1ls avatar tkna91 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

wttrbar's Issues

Assign Different Characters?

Hey there, thanks for working on this :-) I'm just setting up waybar on Hyprland and it looks great.

However I'm wondering if there is a config hidden somewhere where I can change the default characters used for the different weather states (sun emoji, rain emoji, etc) and replace with custom ones that match the theme of my waybar?

FeelsLikeC + tempC

What do I need to do to show both "feelslikeC" and "tempC" in the module? Thanks in advance.

Sunrise/Sunset icons not working

I am running wttrbar on waybar in hyprland. The sunrise/sunset icons are not showing correctly on the tooltip despite having a nerd font and weather icons installed. I can't get a screenshot but here is the command line output:

wttrbar --fahrenheit --main-indicator temp_F
{"text":"🌧️ 69","tooltip":"<b>Light rain</b> 69°\nFeels like: 69°\nWind: 9Km/h\nHumidity: 90%\n\n<b>Today, 2023-04-17</b>\n⬆️ 86° ⬇️ 78° 🌅 06:56 AM 🌇 07:45 PM\n03 🌦️  83° Patchy rain possible, Overcast 86%, Rain 79%\n06 🌤️  82° Partly cloudy, Sunshine 85%, Overcast 41%\n09 🌩️  83° Thundery outbreaks possible, Overcast 89%, Sunshine 16%\n12 🌧️  89° Light rain shower, Overcast 94%, Rain 79%\n15 🌧️  87° Light rain shower, Overcast 93%, Rain 75%\n18 🌦️  84° Patchy rain possible, Overcast 84%, Rain 69%\n21 🌦️  81° Patchy rain possible, Overcast 93%, Rain 67%\n\n<b>Tomorrow, 2023-04-18</b>\n⬆️ 84° ⬇️ 74° 🌅 06:55 AM 🌇 07:46 PM\n00 🌦️  79° Patchy rain possible, Overcast 93%, Rain 69%\n03 ☀️  79° Clear, Sunshine 87%\n06 ☀️  78° Clear, Sunshine 89%\n09 ☀️  77° Sunny, Sunshine 90%\n12 ☀️  84° Sunny, Sunshine 92%\n15 ☀️  85° Sunny, Sunshine 86%\n18 ☀️  81° Sunny, Sunshine 87%\n21 ☀️  78° Clear, Sunshine 89%\n\n<b>2023-04-19</b>\n⬆️ 84° ⬇️ 74° 🌅 06:54 AM 🌇 07:46 PM\n00 ☀️  77° Clear, Sunshine 93%\n03 ☀️  77° Clear, Sunshine 90%\n06 ☀️  77° Clear, Sunshine 87%\n09 ☀️  78° Sunny, Sunshine 94%\n12 ☀️  84° Sunny, Sunshine 89%\n15 ☀️  85° Sunny, Sunshine 94%\n18 ☀️  82° Sunny, Sunshine 87%\n21 ☀️  78° Clear, Sunshine 93%\n"}

Oddly enough, the output works here. Obviously a font issue but I am not sure how to configure this in waybar.

--lang is broken

Hey there, I tried to run your script with the --lang parameter and that happened:

 $ RUST_BACKTRACE=1 ./Downloads/wttrbar --lang de
thread 'main' panicked at src/main.rs:116:14:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::unwrap_failed
   4: wttrbar::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
 $ RUST_BACKTRACE=full ./Downloads/wttrbar --lang de
thread 'main' panicked at src/main.rs:116:14:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7faa94f012a5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h56c396e6ec1a6d25
   1:     0x7faa94f3fc1b - core::fmt::write::h8d9f62e4196a6251
   2:     0x7faa94efe76f - std::io::Write::write_fmt::hfeda4b672809964d
   3:     0x7faa94f0107e - std::sys_common::backtrace::print::h92792842c9200fcf
   4:     0x7faa94f02339 - std::panicking::default_hook::{{closure}}::h4fa40162feafd3ea
   5:     0x7faa94f0207d - std::panicking::default_hook::h5a52bd4fbc34f99c
   6:     0x7faa94f027d3 - std::panicking::rust_panic_with_hook::h33e85abbf3f92159
   7:     0x7faa94f0267b - std::panicking::begin_panic_handler::{{closure}}::h6e89e0968a11dcc7
   8:     0x7faa94f01769 - std::sys_common::backtrace::__rust_end_short_backtrace::h6f80b72bde67d6fa
   9:     0x7faa94f023e7 - rust_begin_unwind
  10:     0x7faa94c574f3 - core::panicking::panic_fmt::hb37c2646452904e3
  11:     0x7faa94c5759c - core::panicking::panic::h05304d7a92564453
  12:     0x7faa94c57499 - core::option::unwrap_failed::hb68718cdc2e283e0
  13:     0x7faa94c5bdf7 - wttrbar::main::hecbade2d690cd418
  14:     0x7faa94c76a83 - std::sys_common::backtrace::__rust_begin_short_backtrace::h2c645147f358c919
  15:     0x7faa94c71e19 - std::rt::lang_start::{{closure}}::h578a143f751f65ad
  16:     0x7faa94ef915d - std::rt::lang_start_internal::ha99684538b0582d2
  17:     0x7faa94c5c735 - main

Don't know what is broken. Feel free to close the issue 😉

[Feature] Send notification if there is errors

I am curious if accept adding notifications to wttrbar as there are times that wttr.in is down and the user dose not know that so it would be nice to know if the service is down when it tries to receive the data from wttr.in. Also It would be nice to receive a notification if the location the user types is unknown so if it dose it also displays a notification. I have a current prototype on my machine currently and from what i can tell as the service is down is that it works...

Reason:
As most people are not tech savy to run wttrbar via the command and run it just with waybar it would be nice to show the info via a notification why the module isnt showing/populating with info.

Background color doesnt get apllied in waybar

Hello so I am using waybar and I downloaded and applied it. It works pefectly, but the styling in waybar is the problem. Here is a screenshot that showed it
image
and here is my style.css code for the weather: #custom-weather { border-radius: 0px 10px 10px 0px; padding-left: 4px; padding-right: 12px; background: #11111b; background-size: 0.1px; } I played around with values and other things and nothing works.
The hover feature and time and so on works but just not the background.
Also how do I change the time format in the hover, so when sundow is in 09:50pm, I want 21:50. How do it do it, I tried to look into the exec wttrbar but it is binary. So how do I costumize it?
Edit: Didnt look at old issue, was fixed but I installed it from aur and there it was no fixed or smth like that. So tried to build it but did not work somehow.
Edit 2: So I when I installed it with paru from aur it gets the 0.3.1 version. The outpout of wttrbar is : {"text":"🌤️ 32","tooltip":"<b>Partly cloudy</b> 32°\nFeels like: 34°\nWind: 11Km/h\nHumidity: 28%\n\n<b>Today, 2023-05-31</b>\n⬆️ 32° ⬇️ 14° 🌅 05:19 AM 🌇 08:43 PM\n03 ☀️ 15° Clear, Sunshine 85%\n06 ☀️ 14° Sunny, Sunshine 87%\n09 ☀️ 21° Sunny, Sunshine 94%\n12 ☀️ 31° Sunny, Sunshine 87%\n15 ☀️ 34° Sunny, Sunshine 93%\n18 ☀️ 33° Sunny, Sunshine 92%\n21 ☀️ 21° Clear, Sunshine 86%\n\n<b>Tomorrow, 2023-06-01</b>\n⬆️ 33° ⬇️ 17° 🌅 05:18 AM 🌇 08:44 PM\n00 ☀️ 18° Clear, Sunshine 94%\n03 ☀️ 17° Clear, Sunshine 85%\n06 ☀️ 17° Sunny, Sunshine 89%\n09 ☀️ 25° Sunny, Sunshine 90%\n12 ☀️ 33° Sunny, Sunshine 87%\n15 ☀️ 34° Sunny, Sunshine 91%\n18 ☀️ 32° Sunny, Sunshine 93%\n21 ☀️ 22° Clear, Sunshine 91%\n\n<b>2023-06-02</b>\n⬆️ 29° ⬇️ 16° 🌅 05:18 AM 🌇 08:45 PM\n00 🌦️ 17° Patchy rain possible, Overcast 88%, Rain 69%\n03 ☀️ 17° Clear, Sunshine 91%\n06 🌤️ 16° Partly cloudy, Sunshine 87%, Overcast 34%\n09 ☀️ 22° Sunny, Sunshine 94%\n12 🌤️ 29° Partly cloudy, Sunshine 83%, Overcast 36%\n15 🌩️ 30° Thundery outbreaks possible, Overcast 80%, Sunshine 13%\n18 ☁️ 20° Cloudy, Overcast 94%, Sunshine 12%\n21 🌧️ 17° Light rain shower, Overcast 89%, Rain 77%\n"} This does JUST the wttrbar alone not addions.

[Request] Change Mist Icon to not be a square

I'm not sure what icons are available at all, however every icon other than mist has a more rounded appearance which makes 'mist' stand out as it is nearly a white square. Is there any way this could be changed to a more fitting icon?

Block until a connection is available

Hello!

I just today found this repo and I'm loving it so far. I have one small gripe however. I'm on a laptop, so as a battery saving feature, wifi gets shut off once the lid closes. This causes problems though as wttrbar tries to get data back before a connection is established once I open the laptop lid.

I believe the best solution for this is to block the main thread until a connection is established, so that the get call can finish successfully.

For now, I have

"custom/weather": {
        "format": "{}° ",
        "tooltip": true,
        "interval": 3600,
        "exec": "exit=101; while [ $exit = 101 ]; do wttrbar --main-indicator temp_F --fahrenheit; exit=$(echo $?); sleep 1; done",
        "return-type": "json"
    },

in my waybar config, which works, but it's inefficient.

Thanks!

Bug: thread 'main' panicked at src/main.rs:61:64

Hi, I just installed wttrbar via AUR: aur/wttrbar 0.10.1-1.

However, when running wttrbar without parameters and with the example parameters provided, I get an error message:

$ RUST_BACKTRACE=full wttrbar --date-format "%m/%d" --location Paris --hide-conditions
thread 'main' panicked at src/main.rs:61:64:
called `Result::unwrap()` on an `Err` value: reqwest::Error { kind: Decode, source: Error("expected value", line: 1, column: 1) }
stack backtrace:
   0:     0x58c5e08d9495 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h01ae9338a6ae91eb
   1:     0x58c5e09007e3 - core::fmt::write::h491257998796a622
   2:     0x58c5e08d68ff - std::io::Write::write_fmt::hb2c64deac04aca6a
   3:     0x58c5e08d92a0 - std::sys_common::backtrace::print::h06f8cce91d6289fa
   4:     0x58c5e08da915 - std::panicking::default_hook::{{closure}}::hcd1fdb5834ba5bf8
   5:     0x58c5e08da693 - std::panicking::default_hook::h40cebc24e84e383d
   6:     0x58c5e08dada8 - std::panicking::rust_panic_with_hook::h619a773c3e95c6fc
   7:     0x58c5e08dac86 - std::panicking::begin_panic_handler::{{closure}}::h991678da18466d9f
   8:     0x58c5e08d9989 - std::sys_common::backtrace::__rust_end_short_backtrace::h88c53d196138c39d
   9:     0x58c5e08da9d7 - rust_begin_unwind
  10:     0x58c5e063f826 - core::panicking::panic_fmt::h63d411b0acff0bd2
  11:     0x58c5e063fcd6 - core::result::unwrap_failed::hd26e04125959b951
  12:     0x58c5e0643b0e - wttrbar::main::he8b6c9446964fc47
  13:     0x58c5e065e9f6 - std::sys_common::backtrace::__rust_begin_short_backtrace::hc62a5a693acffca3
  14:     0x58c5e065d34c - std::rt::lang_start::{{closure}}::he45106e15e501cc6
  15:     0x58c5e08d11ee - std::rt::lang_start_internal::h89fc545bf879bd54
  16:     0x58c5e06444a4 - main
  17:     0x72a38e079c88 - <unknown>
  18:     0x72a38e079d4c - __libc_start_main
  19:     0x58c5e063fe75 - _start

wttrbar giving a panic result

Logged in just now and noticed that weather wasn't showing. Tried running wttrbar in a terminal and got a panic. I used RUST_BACKTRACE=full and got this:

[$] <> RUST_BACKTRACE=full wttrbar
thread 'main' panicked at src/main.rs:61:64:
called Result::unwrap() on an Err value: reqwest::Error { kind: Decode, source: Error("expected value", line: 1, column: 1) }
stack backtrace:
0: 0x5973ab0614d5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h367d587903c05733
1: 0x5973ab086abb - core::fmt::write::h90d6c7093938e590
2: 0x5973ab05e96f - std::io::Write::write_fmt::hf166be129b5ac403
3: 0x5973ab0612ae - std::sys_common::backtrace::print::h16f4e54dda428f87
4: 0x5973ab062569 - std::panicking::default_hook::{{closure}}::h421dd5e2264b9ca7
5: 0x5973ab0622ad - std::panicking::default_hook::hd6ec143ee36c91c5
6: 0x5973ab062a03 - std::panicking::rust_panic_with_hook::he0e1ddfdd1ef8a31
7: 0x5973ab0628e4 - std::panicking::begin_panic_handler::{{closure}}::h75fca2fc3c1ec62d
8: 0x5973ab061999 - std::sys_common::backtrace::__rust_end_short_backtrace::h9d480d72ed19fe3c
9: 0x5973ab062617 - rust_begin_unwind
10: 0x5973aadca4a3 - core::panicking::panic_fmt::h10c3ee83b4e55229
11: 0x5973aadca956 - core::result::unwrap_failed::h635713c629d81684
12: 0x5973aadce94d - wttrbar::main::h3eab8b0daf843a7d
13: 0x5973aade8976 - std::sys_common::backtrace::__rust_begin_short_backtrace::h2075f8f060ba5aba
14: 0x5973aade23ec - std::rt::lang_start::{{closure}}::h90594ae5817e8d19
15: 0x5973ab0593d0 - std::rt::lang_start_internal::h5add80e16e4e0045
16: 0x5973aadcf2f4 - main
17: 0x7643f0450c88 -
18: 0x7643f0450d4c - __libc_start_main
19: 0x5973aadcabf5 - _start
20: 0x0 -

Not sure what the issue is.

EDIT: using Arch linux and Hyprland

show moonphase icon after sunset

This is a great project. I have crafted something very similar to this myself, without the tooltips.

One thing I did was to change the indicator icon from the current condition icon to the moonphase icon after sunset since it made more sense to me, and provided more information/eye candy. Then, after sunrise, restore the indicator icon to be the current condition.

Would you consider adding this feature?

Styling the widget

How can I style the widget? The documentation doesn't mention the widget's class or id that would allow us to style in in waybar's css file.

Mainly I want to adjust/customize the widget's margin on my bar.

Wind in MPH would be a nice option

Yes, I know there are only a few of countries in the world that do not use the metric system, but there are lots of us in those countries.

You would probably be better off dropping the --fahrenheit option, and just adding an option to enable US units with the "?units=u" option to wttr.in instead.

OR maybe a way for the user to pass CUSTOM OPTIONS that will be added to the request URL.

Custom indicator implementation

Hello and thank you for the wttrbar )
It almost fully suit my needs, but I'd like to have an option to customize text output (having tamp_c and FeelsLikeC together for example). So I made a fork and did some changes.
First one is clap integration as I think it is simpler to extend parameters with it - nut-3@5408fdc
Second one is adding --custom-indicator - nut-3@e0eb295
If you consider that changes can be useful, I can make a PR, or feel free to just copy some parts.

wttrbar causes sway to fail to load

I've just switched from the original wttr script to wttrbar. Since switching sway fails to fully load on startup. When starting up I see just a grey screen with a cursor until I manually open a terminal window. Then everything loads correctly, including wttrbar.

I've isolated the issue to adding the --location variable, as when I remove it from my waybar config waybar and sway (Chrome windows, sway background, etc) load as expected.

"exec": "/.config/waybar/Scripts/wttrbar", loads with no issues
"exec": "
/.config/waybar/Scripts/wttrbar --location London", causes sway to hang

A colleague built a separate script that sets the --location variable outside of the config file and that solves the issue, but it feels sub-optimal to have to create a separate script.

wind direction emoticon

So before i found this project i was using to display the weather this command.

curl wttr.in/location?format=2 -s

With this command i was getting this out put.

☀️ 🌡️+31°C 🌬️↙14km/h

I would like to keep this out put and also keep the tool-tip that your module provide. Can i do this ?

I can not find how to display the wind direction with this arrow who points like the compass.

All the other things i manage to replicate.

which font is used

sorry this may be a stupid question but can you tell me which font is being used here i am using the python version and everything seems to work fine i just need to know what font is being used as some icons are showing unknown characters and some are straight up empty space
thanks

There is a typo in the project description

Hi.

The repository is described in the "About" section as follows:

Custom module for showing the weather in Waybar, using the great wttr.io

I guess it should be "wttr.in" not "wttr.io". 👍

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.