Git Product home page Git Product logo

weather-polybar-plugin's Introduction

weather-polybar-plugin

Weather plugin for the polybar panel

preview

Description

This Polybar plugin uses OpenWeather API to get and display information about the current weather, including the type of event (clear, moderate rain, fog etc.), temperature (Celsius, Fahrenheit or Kelvin) and an alert for strong winds. The icons change accordingly with the local sunrise and sunset times.

The colors are easily customizable via constants defined at the beginning of the script.

You will need to provide your personal (and free) api key that you can obtain at https://openweathermap.org/api

Installation

  1. Copy and paste your API key in a simple text file. The default location is $HOME/.owm-key
  2. Put the script where you want, and
  3. Make the script executable via chmod +x /path/to/your/script
  4. Add this to your Polybar config file:
[module/weather]
type = custom/script
exec = /PATH/TO/YOUR/SCRIPT.sh
tail = false
interval = 960
  1. Add the plugin to your polybar panel

Configuration

Take a look at the beginning of the script for all the settings.

You must use a NerdFont https://www.nerdfonts.com

Change CITYNAME and COUNTRYCODE with your desired location.

Set WEATHER_FONT_CODE to the polybar font you want to use to display the weather type and wind icon, and set the TEMP_FONT_CODE to the font for the thermometer icon (it was too big with the first font)

You can change the text language by setting the LANG variable. You can find the available languages and their codes at https://openweathermap.org/current#list

Debugging

Run weather-plugin.sh -d in the terminal in order to see the raw api response

weather-polybar-plugin's People

Contributors

capezotte avatar guidofe avatar lars-vc avatar sixwinger avatar zkwinkle 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

weather-polybar-plugin's Issues

add to redme

Dude, cool guide, but please add about the need to install JQ and BC

Weather and Wind icon too small

Hi, nice polybar weather module.
How to make the weather and wind icons bigger ? I already use nerd fonts in my polybar bar.
The temp icon shows with the right size.

PS. Would be nice with the requirements mentions jq and bc packages.

[Doc] Setting font

Hi,
Thanks for you're work it seem's nice, but I can't config the weather icons.

I have weather-icons install on my system but I don't really know how to setting it. What's 4 mean in WEATHER_FONT_CODE ? same issue for TEMP_FONT_CODE

The script works, I have the forecast and the temp print.

Thanks.

Line 129: jq: command not found

here is the output:

$ ./weather.sh -d
{"coord":{"lon":26.1063,"lat":44.4323},"weather":[{"id":800,"main":"Clear","description":"cer senin","icon":"01n"}],"base":"stations","main":{"temp":16.31,"feels_like":15.67,"temp_min":14.99,"temp_max":17.7,"pressure":1020,"humidity":64},"visibility":10000,"wind":{"speed":2.57,"deg":10},"clouds":{"all":0},"dt":1665169255,"sys":{"type":2,"id":2037828,"country":"RO","sunrise":1665116407,"sunset":1665157593},"timezone":10800,"id":683506,"name":"București","cod":200}

./weather.sh: line 129: jq: command not found

[Doc] Misspelling in README

Hello!
I appreciate your work with this plugin.

I've found an slight error in the readme: Celsious should be Celsius

Temperature units (°C or °F) not showing

I'm on Fedora 38/i3wm, I haven't edited the .sh yet, the temperature units (whether metric or imperial) are not showing, I just see the temp icon followed by a bare number. I can't figure out the cause for this, any ideas?

remove thermometer

Hi there, how can I remove the thermometer icon so it just displays "[weather icon] [description] [temperature]"?

weather-plugin.sh : line 129: jq: command not found

The script throws an error: line 129: jq: command not found.

Running the script separately in the terminal produces the following response:


$ bash weather-plugin.sh -d
{"coord":{"lon":12.4839,"lat":41.8947},"weather":[{"id":800,"main":"Clear","description":"clear sky","icon ":"01d"}],"base":"stations","main":{"temp":11.42,"feels_like":10.86,"temp_min":10.55,"temp_max":14.67,"pressure":1027 ,"humidity":86},"visibility":10000,"wind":{"speed":2.57,"deg":40},"clouds":{"all":0},"dt":1671354770, "sys":{"type":2,"id":2037790,"country":"IT","sunrise":1671345159,"sunset":1671378033},"timezone":3600,"id":3169070, "name":"Rome","code":200}
weather-plugin.sh: line 129: jq: command not found
  • the API is written correctly,
  • the path to the script is correct,
  • the script is executable,
  • in the polybar I see the same error: "line 129: jq command not found"

This line in the script itself: RESPONSECODE=echo $RESPONSE | jq .code`
I didn't change the script.

Weather description dosen't display accented characters

As said in title the weather description just gets cut off when it gets to a character like 'ž'. It is probably an issue on line 318 (DESCRIPTION=echo "$RESPONSE" | jq .weather[0].description | tr -d '"' | sed 's/.*/\L&/; s/[a-z]*/\u&/g'" ") and could just be fixed by changing the sed to include the accented characters.

Feature: Get location by ip

Currently you have the location hardcoded, which is a bit annoying for laptops. So I propose getting to location based on ip, vpn users could then opt out of it by editting the script. How I did it locally:

tss=`curl -s ifconfig.me`  # == ip%
IP=${tss::-1}              # == ip
CITY_NAME=$(curl -s https://ipinfo.io/$IP | jq -r ".city")
COUNTRY_CODE=$(curl -s https://ipinfo.io/$IP | jq -r ".country")

If you like this idea ill make a pr

Some weather icons rendered half

image

P.S I replaced haze icon with the rain icon to show the issue. You can see that the rain icon cloud is cut off from right

Haze icon however is shown correctly. But icons like rain do not appear fully. How can I fix this?

Inteer expression expected!

The script does not work for me and running the script in a terminal gives this out

./weather-plugin.sh: line 117: [: "404": integer expression expected
./weather-plugin.sh: line 132: [: null: integer expression expected
./weather-plugin.sh: line 140: [: null: integer expression expected
./weather-plugin.sh: line 148: [: null: integer expression expected
./weather-plugin.sh: line 156: [: null: integer expression expected
./weather-plugin.sh: line 164: [: null: integer expression expected
./weather-plugin.sh: line 168: [: null: integer expression expected
./weather-plugin.sh: line 172: [: null: integer expression expected
./weather-plugin.sh: line 176: [: null: integer expression expected
./weather-plugin.sh: line 185: [: null: integer expression expected
./weather-plugin.sh: line 194: [: null: integer expression expected
./weather-plugin.sh: line 211: bc: command not found
./weather-plugin.sh: line 222: bc: command not found
./weather-plugin.sh: line 222: [: -eq: unary operator expected
./weather-plugin.sh: line 248: [: null: integer expression expected
./weather-plugin.sh: line 250: bc: command not found
./weather-plugin.sh: line 250: [: -eq: unary operator expected
 %{T4}%{F#f43753}%{F-}%{T-} Null | %{F#FFFFFF}%{T2}%{T-}%{F-} null%{T2}糖%{T-}

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.