From 04d6b909e19afccb6984dbd3d144094cbdcc164c Mon Sep 17 00:00:00 2001 From: candifloss Date: Fri, 13 Dec 2024 18:56:01 +0530 Subject: [PATCH] Updated weather script --- sh/values/weather/weather.example.sh | 45 ++++++++++--------- yuck/panel/panel_widgs/panel_weather_ico.yuck | 4 +- yuck/vars/vars.yuck | 5 +-- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/sh/values/weather/weather.example.sh b/sh/values/weather/weather.example.sh index 104c120..baa42a3 100755 --- a/sh/values/weather/weather.example.sh +++ b/sh/values/weather/weather.example.sh @@ -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 \ No newline at end of file +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' \ No newline at end of file diff --git a/yuck/panel/panel_widgs/panel_weather_ico.yuck b/yuck/panel/panel_widgs/panel_weather_ico.yuck index a20edf9..623b69e 100644 --- a/yuck/panel/panel_widgs/panel_weather_ico.yuck +++ b/yuck/panel/panel_widgs/panel_weather_ico.yuck @@ -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}℃" ) ) \ No newline at end of file diff --git a/yuck/vars/vars.yuck b/yuck/vars/vars.yuck index 899f15d..20f6a68 100644 --- a/yuck/vars/vars.yuck +++ b/yuck/vars/vars.yuck @@ -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