Updated weather script
This commit is contained in:
parent
99f8b23ad0
commit
04d6b909e1
@ -1,21 +1,26 @@
|
||||
curl "https://api.openweathermap.org/data/2.5/weather?&units=metric&id=YourIdHere&appid=YouAPIKeyHere"
|
||||
#! /bin/bash
|
||||
|
||||
#declare -A icon
|
||||
#icon["01d"]="" # Clear sky day.
|
||||
#icon["01n"]="" # Clear sky night.
|
||||
#icon["02d"]="" # Few clouds day.
|
||||
#icon["02n"]="" # Few clouds night.
|
||||
#icon["03d"]="" # Scattered clouds day.
|
||||
#icon["03n"]="" # Scattered clouds night.
|
||||
#icon["04d"]="" # Broken clouds day.
|
||||
#icon["04n"]="" # Broken clouds night.
|
||||
#icon["09d"]="" # Shower rain day.
|
||||
#icon["09n"]="" # Shower rain night.
|
||||
#icon["10d"]="" # Rain day.
|
||||
#icon["10n"]="" # Rain night
|
||||
#icon["11d"]="" # Thunderstorm day.
|
||||
#icon["11n"]="" # Thunderstorm night
|
||||
#icon["13d"]="" # Snow day. Snowflake alternative:
|
||||
#icon["13n"]="" # Snow night. Snowflake alternative:
|
||||
#icon["50d"]="" # Mist day.
|
||||
#icon["50n"]="" # Mist night
|
||||
declare -A icon
|
||||
icon["01d"]="" # Clear sky day.
|
||||
icon["01n"]="" # Clear sky night.
|
||||
icon["02d"]="" # Few clouds day.
|
||||
icon["02n"]="" # Few clouds night.
|
||||
icon["03d"]="" # Scattered clouds day.
|
||||
icon["03n"]="" # Scattered clouds night.
|
||||
icon["04d"]="" # Broken clouds day.
|
||||
icon["04n"]="" # Broken clouds night.
|
||||
icon["09d"]="" # Shower rain day.
|
||||
icon["09n"]="" # Shower rain night.
|
||||
icon["10d"]="" # Rain day.
|
||||
icon["10n"]="" # Rain night
|
||||
icon["11d"]="" # Thunderstorm day.
|
||||
icon["11n"]="" # Thunderstorm night
|
||||
icon["13d"]="" # Snow day. Snowflake alternative:
|
||||
icon["13n"]="" # Snow night. Snowflake alternative:
|
||||
icon["50d"]="" # Mist day.
|
||||
icon["50n"]="" # Mist night
|
||||
|
||||
json=$(curl "https://api.openweathermap.org/data/2.5/weather?&units=metric&id=YourCityIdHere&appid=YouAPIKeyHere")
|
||||
i=$(echo $json | jq -c -r '.weather[0].icon')
|
||||
ico="${icon[$i]}"
|
||||
echo $json | jq -c --arg icon "$ico" '.weather[0].icon = $icon'
|
@ -6,7 +6,7 @@
|
||||
:height "${h}"
|
||||
:width "${h}"
|
||||
;:active true
|
||||
:text "${weather_icon[weather_info.weather[0].icon]}"
|
||||
:tooltip "${weather_info.weather[0].main} ${weather_info.main.temp}"
|
||||
:text "${weather_info.weather[0].icon}"
|
||||
:tooltip "${weather_info.weather[0].main}, ${weather_info.main.temp}℃"
|
||||
)
|
||||
)
|
@ -36,12 +36,9 @@
|
||||
;Weather
|
||||
(defpoll weather_info
|
||||
:interval "5m"
|
||||
:initial "{\"coord\":{\"lon\":0,\"lat\":0},\"weather\":[{\"id\":0,\"main\":\"Unknown\",\"description\":\"unknown\",\"icon\":\"00d\"},{\"id\":0,\"main\":\"Not available\",\"description\":\"not available\",\"icon\":\"00d\"}],\"base\":\"stations\",\"main\":{\"temp\":0,\"feels_like\":0,\"temp_min\":0,\"temp_max\":0,\"pressure\":0,\"humidity\":0,\"sea_level\":0,\"grnd_level\":0},\"visibility\":0,\"wind\":{\"speed\":0,\"deg\":0},\"rain\":{\"1h\":0},\"clouds\":{\"all\":0},\"dt\":978310800,\"sys\":{\"type\":0,\"id\":0,\"country\":\"UK\",\"sunrise\":978310800,\"sunset\":978310800},\"timezone\":0,\"id\":0,\"name\":\"Unknown\",\"cod\":0}"
|
||||
:initial "{\"coord\":{\"lon\":0,\"lat\":0},\"weather\":[{\"id\":0,\"main\":\"Unknown\",\"description\":\"unknown\",\"icon\":\"\"},{\"id\":0,\"main\":\"Not available\",\"description\":\"not available\",\"icon\":\"00d\"}],\"base\":\"stations\",\"main\":{\"temp\":0,\"feels_like\":0,\"temp_min\":0,\"temp_max\":0,\"pressure\":0,\"humidity\":0,\"sea_level\":0,\"grnd_level\":0},\"visibility\":0,\"wind\":{\"speed\":0,\"deg\":0},\"rain\":{\"1h\":0},\"clouds\":{\"all\":0},\"dt\":978310800,\"sys\":{\"type\":0,\"id\":0,\"country\":\"UK\",\"sunrise\":978310800,\"sunset\":978310800},\"timezone\":0,\"id\":0,\"name\":\"Unknown\",\"cod\":0}"
|
||||
`sh/values/weather/weather.sh`
|
||||
)
|
||||
(defvar weather_icon
|
||||
"{\"01d\":\"\",\"01n\":\"\",\"02d\":\"\",\"02n\":\"\",\"03d\":\"\",\"03n\":\"\",\"04d\":\"\",\"04n\":\"\",\"09d\":\"\",\"09n\":\"\",\"10d\":\"\",\"10n\":\"\",\"11d\":\"\",\"11n\":\"\",\"13d\":\"\",\"13n\":\"\",\"50d\":\"\",\"50n\":\"\"}"
|
||||
)
|
||||
|
||||
;WIndow managers
|
||||
(deflisten leftwm_state
|
||||
|
Loading…
Reference in New Issue
Block a user