Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Waybar/weather #254

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

Guillaumecoi
Copy link

@Guillaumecoi Guillaumecoi commented Feb 13, 2025

Pull Request

Request is based on issue 252

Description

Tweaks to the weather Script to make it more versatile

  • Weather in waybar now has different configurations that can be set in ~/.local/state/hyde/config.
  • Variable that can be set, the options, default:
    • TEMP_UNIT : c or f (default: c)
    • TIME_FORMAT: 12h or 24h (default: 12h)
    • WINDSPEED_UNIT: km/h or mph (default: Km/h)
    • SHOW_ICON: True or False (default: True)
    • SHOW_LOCATION: True or False (default: False)
    • SHOW_TODAY_DETAILS: True or False (default: True)
    • FORECAST_DAYS: 0,1,2,3 (default: 3)
    • WAYBAR_WEATHER_LOC: Placename (default: '', based on IP location)
      If the input would be invalid it is automatically changed into the default.
  • The standard layout has been made easier to read.

Type of change

Please put an x in the boxes that apply:

  • [ x] Bug fix (non-breaking change which fixes an issue)
  • [ x] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (non-breaking change; modified files are limited to the documentations)
  • Technical debt (a code change that does not fix a bug or add a feature but makes something clearer for devs)
  • Other (provide details below)

Checklist

Please put an x in the boxes that apply:

  • [ x] I have read the CONTRIBUTING document.
  • [ x] My code follows the code style of this project.
  • [ x] My commit message follows the commit guidelines.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added a changelog entry.
  • [ x] I have added necessary comments/documentation to my code.
  • [ x] I have added tests to cover my changes.
  • [ x] I have tested my code locally and it works as expected.
  • [ x] All new and existing tests passed.

Screenshots

How it it was: (ignore my clock)

image

How it is now with default settings:

image

Example with changed settings:

image
image

Additional context

  • I could write a script so that clock also uses the variable to display 12h or 24h
  • Extra settings are possible as long as it can be retrieved from this api: https://wttr.in/?format=j1

@kRHYME7
Copy link
Contributor

kRHYME7 commented Feb 13, 2025

Thanks, @Guillaumecoi. In this repo, we exposed ~/.config/hyde/config.toml.

https://github.com/HyDE-Project/HyDE/blob/ec19995601392c6660a5cf64d56f6b8b86eec0b5/Configs/.local/share/hyde/config.toml#L129C1-L131C1
example:

[waybar.weather]
loc= true

As bash do not have an ability to parse a toml file, we have an intermediary script that watches the ~/.config/hyde/config.toml for changes. Once changed, it will generate the state file ~/.local/state/hyde/config .

So I would suggest renaming the variables with WEATHER_ prefixes.

    WEATHER_TEMP_UNIT : c or f (default: c)
    WEATHER_TIME_FORMAT: 12h or 24h (default: 12h)
    WEATHER_WINDSPEED_UNIT: km/h or mph (default: Km/h)
    WEATHER_SHOW_ICON: True or False (default: True)
    WEATHER_SHOW_LOCATION: True or False (default: False)
    WEATHER_SHOW_TODAY_DETAILS: True or False (default: True)
    WEATHER_FORECAST_DAYS: 0,1,2,3 (default: 3)

For this one let's suport 2 variables for now, and will deprecate soon.

WAYBAR_WEATHER_LOC: Placename (default: '', based on IP location)
WEATHER_LOC: Placename (default: '', based on IP location)

This way the config.toml interface will have

[weather]
temperature_unit=c
time_format=
windspeed_unit=
show_icon=
show_location=
show_today=
forecast_days=

@Guillaumecoi
Copy link
Author

Thank you for your explanation since I did not get how the .toml file worked. I really like this solution to handle env variables, it is very clean.

  • I changed the variable names in the Python script and tested it by setting the variables in ~/.config/hyde/config.toml.

  • I also set the default variables in ~.local/share/hyde/config.toml. So it is more clear how to use them.

I still have some questions:

  • "For this one let's support 2 variables for now, and will deprecate soon." My Script does not read the variable WAYBAR_WEATHER_LOC anymore and that is why I deleted it. Is it best to avoid this so people don't lose there loc setting upon updating? If so wouldn't it be better to place all variables under: [waybar.weather] so that I dont have to check 2 variables?

  • Is it correct that the variables in ~/.config/hyde/config.toml are not used but are more like a template to show how you can use ~/.config/hyde/config.toml. I think from taking a look at the scripts it does not use these values but it uses the default values in the script which are identical to those in ~/.config/hyde/config.toml

Copy link
Contributor

@dieBakterie dieBakterie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the typos in config.toml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants