You are not logged in.
I think we analyzed all the lines well, except for Line 3 and Line 6.
${execi 600 sed -n '3p' $HOME/Accuweather_RSS_conky_script/weather}
...
${execi 600 sed -n '6p' $HOME/Accuweather_RSS_conky_script/weather}
In my last screenshots I used the date command instead of the weather file:
${color 48bcff}${execi 600 date '+%a %d %b %Y'}${color}
...
${color 48bcff}${execi 600 date -d '+1 day' '+%a %d %b %Y'}${color}
I like the format used by Gis Weather with non-working days colored in red.
My Line 3 and Line 6 now look like this:
${if_match "${execi 600 date '+%a'}" == "Sat"}${color ff8080}\
${else}\
${if_match "${execi 600 date '+%a'}" == "Sun"}${color ff8080}\
${else}${color 48bcff}${endif}${endif}\
${execi 600 date '+%a , %d/%m %Y'}${color}
...
${if_match "${execi 600 date -d '+1day' '+%a'}" == "Sat"}${color ff8080}\
${else}\
${if_match "${execi 600 date -d '+1day' '+%a'}" == "Sun"}${color ff8080}\
${else}${color 48bcff}${endif}${endif}\
${execi 600 date -d '+1day' '+%a , %d/%m %Y'}${color}
If you want another format, open the terminal:
$ man date
Scroll down and find 'FORMAT controls the output'.
If people would know how little brain is ruling the world, they would die of fear.
Offline
I think we analyzed all the lines well, except for Line 3 and Line 6.
In my last screenshots I used the date command instead of the weather file:
I have been using the "date" command in my conkys for what seems like forever.
Oldest dated post with Teo weather script on this forum is on page 1 of this thread. Another is here as an example. Others are lost since the #! Forum is down.
My version of the Accu_RSS script:
${membar 0}
${font conkyweather:size=30}${color8}${execpi 600 sed -n '2p' /media/5/Conky/accuweather_rss/weather}${color}${font}
${voffset -30}${goto 75}${color1}BsAS Arg.${color}
${execi 60 echo `date --date="0 day" | awk '{print $1,$2,$3}'`}${color} ${time %T}
${execpi 600 sed -n '1p' /media/5/Conky/accuweather_rss/weather | awk '{$NF="";sub(/[ \t]+$/,"")}1' | awk '{$1=""; print $0}' | awk '{print substr($0,2)}' | cut -c1-30} \
${execpi 600 sed -n '1p' /media/5/Conky/accuweather_rss/weather | awk 'NF>1{print $NF}' | sed 's/C/°C/g'}
${color1}FORECAST${color}
${font conkyweather:size=30}${color8}${execpi 600 sed -n '5p' /media/5/Conky/accuweather_rss/weather}${color}${font}
${color1}${execi 600 echo `date --date="0 day" | awk '{print $1,$2,$3}'`}${color}
${execpi 600 sed -n '4p' /media/5/Conky/accuweather_rss/weather|awk '{print $1,$2"'°C'",$4,$5"'°C'"}'}
${execpi 600 sed -n '4p' /media/5/Conky/accuweather_rss/weather|cut -d ' ' -f7-}
${font conkyweather:size=30}${color8}${execpi 600 sed -n '8p' /media/5/Conky/accuweather_rss/weather}${color}${font}
${color1}${execi 600 echo `date --date="1 day" | awk '{print $1,$2,$3}'`}${color}
${execpi 600 sed -n '7p' /media/5/Conky/accuweather_rss/weather|awk '{print $1,$2"'°C'",$4,$5"'°C'"}'}
${execpi 600 sed -n '7p' /media/5/Conky/accuweather_rss/weather|cut -d ' ' -f7-}
${membar 0}
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
I like the format used by Gis Weather with non-working days colored in red.
Of course you don't have to wait for the weekend to test my code.
Today is Wednesday.
Replace temporary Line 3 with:
${if_match "${execi 600 date '+%a'}" == "Wed"}${color ff8080}\
${else}\
${if_match "${execi 600 date '+%a'}" == "Sun"}${color ff8080}\
${else}${color 48bcff}${endif}${endif}\
${execi 600 date '+%a , %d/%m %Y'}${color}
Restart conky.
Is Line 3 red?
Repeat similarly with Line 6 but don't forget that tomorrow is Thursday:
${if_match "${execi 600 date -d '+1day' '+%a'}" == "Thu"}${color ff8080}\
${else}\
${if_match "${execi 600 date -d '+1day' '+%a'}" == "Sun"}${color ff8080}\
${else}${color 48bcff}${endif}${endif}\
${execi 600 date -d '+1day' '+%a , %d/%m %Y'}${color}
Restart conky.
Is Line 6 red?
Disable the temporary changes and revert to the original code.
Done.
If people would know how little brain is ruling the world, they would die of fear.
Offline
I'm slowly finishing testing the awesome acc_RSS script.
Today I noticed something else interesting for those using basic conky.
When we have a case: High: XX°C Low: XX°C the weather description in the next line is not aligned and starts with a blank space:
$ sed -n '7p' $HOME/Accuweather_RSS_conky_script/weather|cut -c21-40
Warm with some sun
The solution is:
$ sed -n '7p' $HOME/Accuweather_RSS_conky_script/weather|cut -c21-40 | sed -e 's/^[ \t]*//'
Warm with some sun
Repeat the same in the next line because you don't want a blank space at the beginning:
$ sed -n '7p' $HOME/Accuweather_RSS_conky_script/weather|cut -c41-60 | sed -e 's/^[ \t]*//'
Line 4:
$ sed -n '4p' $HOME/Accuweather_RSS_conky_script/weather|cut -c21-40 | sed -e 's/^[ \t]*//'
$ sed -n '4p' $HOME/Accuweather_RSS_conky_script/weather|cut -c41-60 | sed -e 's/^[ \t]*//'
Last edited by marens (2024-02-08 14:38:04)
If people would know how little brain is ruling the world, they would die of fear.
Offline
Mine work fine, no space:
08 Feb 24 @ 13:45:44 ~
$ sed -n '4p' /media/5/Conky/accuweather_rss/weather|awk '{print $1,$2"'°C'",$4,$5"'°C'"}'
High: 31°C Low: 25°C
08 Feb 24 @ 13:45:49 ~
$ sed -n '4p' /media/5/Conky/accuweather_rss/weather|cut -d ' ' -f7-
Humid; breezy this afternoon
08 Feb 24 @ 13:46:08 ~
$ sed -n '7p' /media/5/Conky/accuweather_rss/weather|awk '{print $1,$2"'°C'",$4,$5"'°C'"}'
High: 31°C Low: 24°C
08 Feb 24 @ 13:46:26 ~
$ sed -n '7p' /media/5/Conky/accuweather_rss/weather|cut -d ' ' -f7-
High clouds; warm, humid
08 Feb 24 @ 13:46:42 ~
$
Also if:
sed -n '4p' /media/5/Conky/accuweather_rss/weather|cut -d ' ' -f7-
and
sed -n '7p' /media/5/Conky/accuweather_rss/weather|cut -d ' ' -f7-
work without the space, that means that line 1:
sed -n '1p' /media/5/Conky/accuweather_rss/weather | awk '{$NF="";sub(/[ \t]+$/,"")}1' | awk '{$1=""; print $0}' | awk '{print substr($0,2)}' | cut -c1-30
and
sed -n '1p' /media/5/Conky/accuweather_rss/weather | awk 'NF>1{print $NF}' | sed 's/C/°C/g'
can be made as a nice and simple 1 line:
$ sed -n '1p' /media/5/Conky/accuweather_rss/weather|cut -d ' ' -f2-| sed 's/C/°C/g'
Thunderstorms: 25°C
Consider my Line 1 updated.
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
@Sector11
Today I noticed something else interesting for those using basic conky.
As you can see, my post is intended for beginners.
I want them to understand how to adapt this conky to themselves and I try to encourage them to try.
In a simple way.
If people would know how little brain is ruling the world, they would die of fear.
Offline
@marens
My a simple way.
fragment acc_RSS:
.....
sed -i -e 's/_31x31.*$//g' -e 's/^.*\/icons\///g' $HOME/Accuweather_RSS_conky_script/weather
# add ↓↓↓↓↓
sed -i -e 's/[^0-9]C /°C /g' -e '1s/C /°C/' $HOME/Accuweather_RSS_conky_script/weather
# add ↑↑↑↑↑
sed -i -e '1s/.$//' -e '3s/.$//' -e '6s/.$//' $HOME/Accuweather_RSS_conky_script/weather
......
fragment .conkyrc_Acc_RSS:
.......
# ### currently #####
##########################################
#
${image $HOME/Accuweather_RSS_conky_script/day_1.png -p -1,20 -s 70x50}#
#${voffset -5}${font conkyweather:size=30}${execi 60 sed -n '2p' $HOME/Accuweather_RSS_conky_script/weather}${font}${voffset -25}#
##########################################
#
${goto 75}${execi 60 sed -n '1p' $HOME/Accuweather_RSS_conky_script/weather | awk '{print $1,$2,$3}'}
#
${goto 75}${execi 60 sed -n '1p' $HOME/Accuweather_RSS_conky_script/weather | awk '{print $4,$5,$6}'}
#
${goto 75}${execi 60 sed -n '1p' $HOME/Accuweather_RSS_conky_script/weather | awk '{print $7,$8,$9}'}
# ### day #####
#${execi 60 sed -n '3p' $HOME/Accuweather_RSS_conky_script/weather}
# man date
${goto 85}${execi 60 date -d $(sed -n '3p' $HOME/Accuweather_RSS_conky_script/weather | awk '{print $1}') +'%d %b %a'}
##########################################
#
${image $HOME/Accuweather_RSS_conky_script/day_2.png -p -1,90 -s 70x50}#
#${voffset 2}${font conkyweather:size=30}${execi 60 sed -n '5p' $HOME/Accuweather_RSS_conky_script/weather}${font}${voffset -32}#
##########################################
........
Offline
Hi @il.harun.
Yes.
I can see.
You replaced 'C ' with '°C ' in the script itself.
In every line weather file.
Afterwards it is easy to display in the conky with small corrections.
Very nice.
I am glad that now we have more solutions for a long-standing bug.
Thanks.
If people would know how little brain is ruling the world, they would die of fear.
Offline
OK.
I finished testing acc_RSS script and everything works as I expected.
Then I tried adding below the moongiant script.
I think it looks good.
I used my plugin to get the position and illumination angle of the moon in real time:
https://forums.bunsenlabs.org/viewtopic … 46#p128546
This is that part in conky:
${color 48bcff}MOON${color}${texeci 500 bash $HOME/Moongiant_conky_script/moongiant}
${voffset 5}${goto 100}Position:
${goto 100}Azimuth: ${texeci 600 cat $HOME/Moongiant_conky_script/illumination_angle | grep -oP '(?<=azimuth = )[^ ]*' | awk -F',' '{print $1}'} °
${goto 100}Altitude: ${texeci 600 cat $HOME/Moongiant_conky_script/illumination_angle | grep -oP '(?<=altitude = )[^ ]*'} °
${voffset -5}\
${if_match "${texeci 600 sed -n '12p' $HOME/Moongiant_conky_script/raw | awk '{print length}'}" == "2"}${goto 35}${else}${endif}\
${if_match "${texeci 600 sed -n '12p' $HOME/Moongiant_conky_script/raw | awk '{print length}'}" == "3"}${goto 33}${else}${endif}\
${if_match "${execpi 600 sed -n '12p' $HOME/Moongiant_conky_script/raw}" == "100%"}${goto 33}${color d4d400}Full\
${else}${execpi 600 sed -n '12p' $HOME/Moongiant_conky_script/raw}${endif}\
${color}${goto 100}${color 00ad00}${texeci 600 sed -n '11p' $HOME/Moongiant_conky_script/raw}${color}
${voffset 5}${alignc}Visibility: ${if_match "${texeci 600 sed -n '1p' $HOME/Moongiant_conky_script/visibility}" == "Under Horizon"}${color ff4040}\
${else}${color 48bcff}${endif}\
${texeci 600 sed -n '1p' $HOME/Moongiant_conky_script/visibility}${color}
${alignc}Distance: ${texeci 600 sed -n '26p' $HOME/Moongiant_conky_script/raw}\
${image $HOME/Moongiant_conky_script/0.png -p 15,340 -s 50x50}
If people would know how little brain is ruling the world, they would die of fear.
Offline
Here is my humble contribution, which may or may not be of use to the knowledgeable members here.
For those of us who do use openweathermap data, you will know that the "wind degree" data point shows the direction from which the wind is coming, not the direction it is blowing towards. It's also in degrees rather than in compass direction points.
Long ago I found a script here: https://github.com/woohgit/conkySimpleForecast
that converted wind degrees to compass points (among all the other things it does), and translated it to display the compass fonts in ConkyWind.otf. The current weather condition uses ConkyWeather.otf .
However, it was not really complete. The TODO note in the script states (among other things):
"- support wind directions http://snowfence.umn.edu/Components/win … table3.htm
# - after sunset, use the night fonts instead of the day fonts"
In other words, it was still displaying the direction the wind was coming from (including the compass wind font). The dev's font.json file also did not include conversion keys for the openweathermap day/night condition codes.
I've sorted out those 2 issues:
- added a 'wind_deg_to_textopp' function [opp=opposite] and made 'wind_deg_to_font' function reference that instead
- added a "fonticon" definition for the openweather day/night icon codes
- in the font.json file, I've added the conversion keys for the day/night icon codes based on the conkyweather font.
Thus, in the sample conky config found at the above github link, you can use "${execi 120 ./conkySimpleForecast -d fonticon}" in place of "${execi 120 ./conkySimpleForecast -d font}" if you want the day/night weather icons instead of the weather id icons.
The amended script and json file are set out below:
script conkySimpleForecast
#!/bin/bash
#
# Fetches weather data from openweathermap.com
# TODO
# - support templates and populate it in one big call
# - support wind directions http://snowfence.umn.edu/Components/winddirectionanddegreeswithouttable3.htm
# - after sunset, use the night fonts instead of the day fonts
# - finish WEATHER_CONDITIONS (http://bluejamesbond.github.io/CharacterMap/)
OPENWEATHERMAP_BASE_URL="http://api.openweathermap.org/data/2.5/"
# tools required
CURL=`which curl`
JQ=`which jq`
if [[ -z "${CURL}" ]]; then
echo "ERROR: curl is not installed."
exit -1
fi
if [[ -z "${JQ}" ]]; then
echo "ERROR: jq is not installed."
exit -1
fi
while getopts ":d:c:q:u:a:q:l:t:i:f:" opt; do
case $opt in
a) API_KEY="${OPTARG}" ;;
c) CACHE_DIR="${OPTARG}" ;;
d) DATATYPE="${OPTARG}" ;;
f) CONFIG="${OPTARG}" ;;
i) CITY_ID="${OPTARG}" ;;
l) LANGUAGE="${OPTARG}" ;;
q) LOCATION="${OPTARG}" ;;
t) TYPE="${OPTARG}" ;;
u) UNITS="${OPTARG}" ;;
\?) echo "Invalid option -${OPTARG}" >&2 ;;
esac
done
if [[ -z "${CONFIG}" ]]; then
CONFIG="config.json"
fi
API_KEY=${API_KEY:-$(cat ${CONFIG} | jq '.api_key' -r)}
CACHE_DIR=${CACHE_DIR:-$(cat ${CONFIG} | jq '.cache_dir' -r)}
CITY_ID=${CITY_ID:-$(cat ${CONFIG} | jq '.city_id' -r)}
LANGUAGE=${LANGUAGE:-$(cat ${CONFIG} | jq '.language' -r)} # valid values are: see languages.txt
LOCATION=${LOCATION:-$(cat ${CONFIG} | jq '.location' -r)}
TYPE=${TYPE:-$(cat ${CONFIG} | jq '.type' -r)} # valid values are [current, forecast]
UNITS=${UNITS:-$(cat ${CONFIG} | jq '.units' -r)}
function lock() {
lockdir="${CACHE_DIR}/refresh.lock"
if mkdir "$lockdir"
then
echo >&2 "successfully acquired lock"
trap 'rm -rf "$lockdir"' 0 # remove directory when script finishes
else
echo >&2 "cannot acquire lock, giving up on $lockdir"
sleep 0.5
fi
}
function get_weather_url() {
url=${OPENWEATHERMAP_BASE_URL}
case $1 in
current)
url+="weather"
;;
forecast)
url+="forecast"
;;
esac
# location
if [[ ! -z "${LOCATION}" ]]; then
url+="?q=${LOCATION}"
fi
# city_id
if [[ ! -z "${CITY_ID}" ]]; then
url+="?id=${CITY_ID}"
fi
# application id
url+="&APPID=${API_KEY}"
# units
url+="&units=${UNITS}"
# lang
url+="&lang=${LANGUAGE}"
# accurate
url+="&type=accurate"
echo $url
}
function get_cache_path() {
case $TYPE in
current)
cache_name="current_weather.cache"
;;
forecast)
cache_name="forecast_weather.cache"
;;
esac
echo ${CACHE_DIR}/${cache_name}
}
#######################################
# Check the cache file and determine
# if it needs to be updated or not
# Globals:
# None
# Arguments:
# None
# Returns:
# 0 or 1
#######################################
function cache_needs_refresh() {
cache_path=$(get_cache_path)
now=$(date +%s)
# if the cache does not exist, refresh it
if [[ ! -f "${cache_path}" ]]; then
return 1
fi
last_modification_date=$(stat -c %Y ${cache_path})
seconds=$(expr ${now} - ${last_modification_date})
if [[ "${seconds}" -gt 120 ]]; then
return 1
else
return 0
fi
}
function fetch_weather() {
cache_needs_refresh
refresh=$?
url=$(get_weather_url ${TYPE})
# echo ${url}
cache_path=$(get_cache_path)
if [[ ! -f "${cache_path}" ]] || [[ "${refresh}" -eq 1 ]]; then
${CURL} -s ${url} > ${cache_path}.$$
# only update the file if we successfully retrieved the JSON
num_of_lines=$(cat "${cache_path}.$$" | wc -c)
if [[ "${num_of_lines}" -gt 200 ]]; then
mv "${cache_path}.$$" ${cache_path}
else
rm -f ${cache_path}.$$
fi
fi
}
function create_cache() {
if [[ ! -d "${CACHE_DIR}" ]]; then
mkdir -p ${CACHE_DIR}
fi
}
function return_field() {
if [[ -z "${DATATYPE}" ]]; then
echo "ERROR: missing datatype. Please provide it via the -p option."
fi
cache_path=$(get_cache_path)
case ${TYPE} in
current)
case ${DATATYPE} in
condition)
data=$(cat ${cache_path} | ${JQ} '.weather[] | .main' -r | paste -sd ',' -)
;;
summary)
data=$(cat ${cache_path} | ${JQ} '.weather[0].description' -r)
;;
temp|pressure|humidity|temp_min|temp_max)
data=$(cat ${cache_path} | ${JQ} ".main.${DATATYPE}" -r | xargs printf "%.f" $p)
;;
clouds)
data=$(cat ${cache_path} | ${JQ} ".clouds.all" -r)"%"
;;
visibility)
data=$(cat ${cache_path} | ${JQ} ".visibility" -r)
;;
wind_speed)
data=$(cat ${cache_path} | ${JQ} ".wind.speed" -r)
;;
wind_deg)
data=$(cat ${cache_path} | ${JQ} ".wind.deg" -r | xargs printf "%.f" $p)
data=$(wind_deg_to_text ${data})
;;
wind_deg_font)
tmp_data=$(cat ${cache_path} | ${JQ} ".wind.deg" -r | xargs printf "%.f" $p)
data=$(wind_deg_to_font ${tmp_data})
;;
sunrise|sunset)
tmp_data=$(cat ${cache_path} | ${JQ} ".sys.${DATATYPE}" -r)
data=$(date -d @"${tmp_data}" "+%H:%M")
;;
city)
data=$(cat ${cache_path} | ${JQ} ".name" -r)
;;
font)
# ${offset 15}${color EAEAEA}${font ConkyWeather:size=46}${execi 120 conkySimpleForecast -d font}${font}${voffset -30}
tmp_data=$(cat ${cache_path} | ${JQ} '.weather[0].id' -r)
data=$(cat ./fonts.json | ${JQ} .[\""$tmp_data"\"] -r)
;;
fonticon)
# ${offset 15}${color EAEAEA}${font ConkyWeather:size=46}${execi 120 conkySimpleForecast -d font}${font}${voffset -30}
tmp_data=$(cat ${cache_path} | ${JQ} '.weather[0].icon' -r)
data=$(cat ./fonts.json | ${JQ} .[\""$tmp_data"\"] -r)
;;
dt)
data=$(cat ${cache_path} | ${JQ} '.dt')
data=$(date -d @${data})
;;
*)
data="N/A"
;;
esac
;;
forecast)
data=$(cat ${cache_path} | ${JQ} '.city.name')
;;
*) echo "Unknown type" ;;
esac
echo $data
}
function wind_deg_to_text() {
local deg=$1
# N 348.75 - 11.25
if [[ "${deg}" -ge 348 ]] || [[ "${deg}" -le 11 ]]; then
echo "N"
# NNE 11.25 - 33.75
elif [[ "${deg}" -gt 11 ]] && [[ "${deg}" -lt 34 ]]; then
echo "NNE"
# NE 33.75 - 56.25
elif [[ "${deg}" -ge 34 ]] && [[ "${deg}" -lt 56 ]]; then
echo "NE"
# ENE 56.25 - 78.75
elif [[ "${deg}" -ge 56 ]] && [[ "${deg}" -lt 78 ]]; then
echo "ENE"
# E 78.75 - 101.25
elif [[ "${deg}" -ge 78 ]] && [[ "${deg}" -lt 101 ]]; then
echo "E"
# ESE 101.25 - 123.75
elif [[ "${deg}" -ge 101 ]] && [[ "${deg}" -lt 123 ]]; then
echo "ESE"
# SE 123.75 - 146.25
elif [[ "${deg}" -ge 123 ]] && [[ "${deg}" -lt 146 ]]; then
echo "SE"
# SSE 146.25 - 168.75
elif [[ "${deg}" -ge 146 ]] && [[ "${deg}" -lt 168 ]]; then
echo "SSE"
# S 168.75 - 191.25
elif [[ "${deg}" -ge 168 ]] && [[ "${deg}" -lt 191 ]]; then
echo "S"
# SSW 191.25 - 213.75
elif [[ "${deg}" -ge 191 ]] && [[ "${deg}" -lt 213 ]]; then
echo "SSW"
# SW 213.75 - 236.25
elif [[ "${deg}" -ge 213 ]] && [[ "${deg}" -lt 236 ]]; then
echo "SW"
# WSW 236.25 - 258.75
elif [[ "${deg}" -ge 236 ]] && [[ "${deg}" -lt 258 ]]; then
echo "WSW"
# W 258.75 - 281.25
elif [[ "${deg}" -ge 258 ]] && [[ "${deg}" -lt 281 ]]; then
echo "W"
# WNW 281.25 - 303.75
elif [[ "${deg}" -ge 281 ]] && [[ "${deg}" -lt 303 ]]; then
echo "WNW"
# NW 303.75 - 326.25
elif [[ "${deg}" -ge 303 ]] && [[ "${deg}" -lt 326 ]]; then
echo "NW"
# NNW 326.25 - 348.75
elif [[ "${deg}" -ge 326 ]] && [[ "${deg}" -lt 348 ]]; then
echo "NNW"
else
echo "N/A"
fi
}
function wind_deg_to_textopp() {
local deg=$1
# N 348.75 - 11.25
if [[ "${deg}" -ge 348 ]] || [[ "${deg}" -le 11 ]]; then
echo "S"
# NNE 11.25 - 33.75
elif [[ "${deg}" -gt 11 ]] && [[ "${deg}" -lt 34 ]]; then
echo "SSW"
# NE 33.75 - 56.25
elif [[ "${deg}" -ge 34 ]] && [[ "${deg}" -lt 56 ]]; then
echo "SW"
# ENE 56.25 - 78.75
elif [[ "${deg}" -ge 56 ]] && [[ "${deg}" -lt 78 ]]; then
echo "WSW"
# E 78.75 - 101.25
elif [[ "${deg}" -ge 78 ]] && [[ "${deg}" -lt 101 ]]; then
echo "W"
# ESE 101.25 - 123.75
elif [[ "${deg}" -ge 101 ]] && [[ "${deg}" -lt 123 ]]; then
echo "WNW"
# SE 123.75 - 146.25
elif [[ "${deg}" -ge 123 ]] && [[ "${deg}" -lt 146 ]]; then
echo "NW"
# SSE 146.25 - 168.75
elif [[ "${deg}" -ge 146 ]] && [[ "${deg}" -lt 168 ]]; then
echo "NNW"
# S 168.75 - 191.25
elif [[ "${deg}" -ge 168 ]] && [[ "${deg}" -lt 191 ]]; then
echo "N"
# SSW 191.25 - 213.75
elif [[ "${deg}" -ge 191 ]] && [[ "${deg}" -lt 213 ]]; then
echo "NNE"
# SW 213.75 - 236.25
elif [[ "${deg}" -ge 213 ]] && [[ "${deg}" -lt 236 ]]; then
echo "NE"
# WSW 236.25 - 258.75
elif [[ "${deg}" -ge 236 ]] && [[ "${deg}" -lt 258 ]]; then
echo "ENE"
# W 258.75 - 281.25
elif [[ "${deg}" -ge 258 ]] && [[ "${deg}" -lt 281 ]]; then
echo "E"
# WNW 281.25 - 303.75
elif [[ "${deg}" -ge 281 ]] && [[ "${deg}" -lt 303 ]]; then
echo "ESE"
# NW 303.75 - 326.25
elif [[ "${deg}" -ge 303 ]] && [[ "${deg}" -lt 326 ]]; then
echo "SE"
# NNW 326.25 - 348.75
elif [[ "${deg}" -ge 326 ]] && [[ "${deg}" -lt 348 ]]; then
echo "SSE"
else
echo "N/A"
fi
}
function wind_deg_to_font() {
local deg=$1
text=$(wind_deg_to_textopp "${deg}")
data=$(cat ./wind_direction.json | ${JQ} ".${text}" -r)
echo $data
}
if [[ -z "${API_KEY}" ]]; then
echo "ERROR: missing api_key. Please provide it via -a myapikey option"
echo "ERROR: Get a free api_key from https://home.openweathermap.org/api_keys"
exit -1
fi
if [[ -z "${LOCATION}" ]] && [[ -z "${CITY_ID}" ]]; then
echo "ERROR: location (-l) or city id (-i) should must be given."
fi
create_cache
fetch_weather
return_field
contents of fonts.json
{
"01d": "a",
"01n": "A",
"02d": "b",
"02n": "B",
"03d": "c",
"03n": "C",
"04d": "d",
"04n": "D",
"09d": "g",
"09n": "G",
"10d": "i",
"10n": "i",
"11d": "k",
"11n": "K",
"13d": "o",
"13n": "O",
"50d": "9",
"50n": "9",
"200": "n",
"201": "n",
"202": "n",
"210": "n",
"211": "n",
"212": "n",
"221": "n",
"230": "n",
"231": "n",
"232": "n",
"300": "j",
"301": "j",
"302": "j",
"310": "j",
"311": "j",
"312": "j",
"313": "j",
"314": "j",
"321": "j",
"500": "g",
"501": "g",
"502": "g",
"503": "g",
"504": "g",
"511": "x",
"520": "j",
"521": "j",
"522": "j",
"531": "j",
"600": "o",
"601": "p",
"602": "q",
"611": "x",
"612": "x",
"615": "x",
"616": "x",
"620": "x",
"621": "x",
"622": "x",
"701": "9",
"711": "4",
"721": "9",
"731": "7",
"741": "0",
"751": "9",
"761": "7",
"762": "9",
"771": "9",
"781": "9",
"800": "a",
"801": "b",
"802": "c",
"803": "d",
"804": "e",
"900": "1",
"901": "2",
"902": "3",
"903": "5",
"904": "5",
"905": "6",
"906": "u",
"951": "6",
"952": "6",
"953": "6",
"954": "6",
"955": "6",
"956": "6",
"957": "6",
"958": "6",
"959": "6",
"960": "6",
"961": "6",
"962": "2"
}
I find the script useful to show the wind direction and wind compass font, even in other openweathermap conkies that don't otherwise use the script.
Last edited by asqwerth (2024-02-15 14:36:01)
Offline
However, it was not really complete. The TODO note in the script states (among other things):
"- support wind directions http://snowfence.umn.edu/Components/win … table3.htm
# - after sunset, use the night fonts instead of the day fonts"
Unfortunately this link does not work (404 - File or directory not found).
Last edited by unklar (2024-02-15 15:21:06)
Offline
I did not use that link at all, which the developer mentioned in his TODO list. No idea what it was all about.
I only edited the dev's own stuff in his github link (paragraph 3 of my post).
Offline
Offline
@asqwerth
Thanks for sharing your openweathermap experience with us.
I think the fonts.json file is a good base to see the relationship between the font and symbols used by openweather and can be easily customized.
It would be nice to see screenshots.
P.S.
I prefer PNG images in conky.
I don't like conky with black semi-transparent background and white/grey letters.
If people would know how little brain is ruling the world, they would die of fear.
Offline
https://i.imgur.com/w6AzQFat.png
Your changes with the wind do not appear here. Maybe I don't understand it either.
There are a lot of ${offset} in the configuration. The master would say "very, very unfavorable".
Based on your screenshot, I believe that the wind changes have been effected.
The "S" = direction from which the wind is coming, which means a weather vane will point North, which your windfont is doing.
I am basing this display style on the Accuweather conky script, where if the wind direction is N (as it is right now in curr_cond file), the compass image/windfont will point South.
The sample conky config was provided by the developer to provide helpful examples of how the script can be used to display different info. If it has too many "offset"s in it, I'm sure members here can do better. ;-)
@marens, I haven't been able to convert to using compass images to display wind direction yet. The nice 2015 Forecast images are available but I've not been successful.
For the other weather condition images, I generally don't use the script in other openweather conkies. Usually I just read the weather icon or weather id values straight from the generated weather.json file and use it with icon sets that are numbered in line with openeweathermap codes. It's only the compass and wind direction info that I like the script for.
Offline
@asqwerth
...
It would be nice to see screenshots.P.S.
I prefer PNG images in conky....
@marens
Here's an example screenshot - the 2 main current weather icons at the top (one is the weather[0].icon the other is the weather[0].id icon), as well as the wind direction font are displayed using the script. [yes, it seems weird to have 2 current weather icons, but I'm still undecided which I prefer. Weather icon provides different night and day icons, but there are fewer such icons; while there are more weather id codes and thus more icons for different weather conditions, but depending on the icon set, some weather condition images contain the sun and thus you get sun images even at night. ]
The weather forecast images on the bottom row are not using the script, and the icons are from the harmattan series of conkies (these happen to be white outline images, but I do have other icon sets for use with openweathermap codes).
PS, I also inserted the moongiant current moon within the compass.
Offline
I haven't been able to convert to using compass images to display wind direction yet. The nice 2015 Forecast images are available but I've not been successful.
Can you give me a command that gives the current wind direction (N, ESE, SSW ...)?
What is the output when there is no wind (CLM)?
If people would know how little brain is ruling the world, they would die of fear.
Offline
I tried to adapt accuweather Forecast_Images_2016 for Gis Weather.
If you like, you can download it:
https://workupload.com/file/SKSu8K7YMHZ
Follow the installation instructions:
https://forums.bunsenlabs.org/viewtopic … 63#p131063
If people would know how little brain is ruling the world, they would die of fear.
Offline
asqwerth wrote:I haven't been able to convert to using compass images to display wind direction yet. The nice 2015 Forecast images are available but I've not been successful.
Can you give me a command that gives the current wind direction (N, ESE, SSW ...)?
What is the output when there is no wind (CLM)?
The commands I utilise in the conky config are:
1) ${execi 120 ./conkySimpleForecast -d wind_deg} -- this is to show the direction the wind is blowing FROM
2) ${execi 120 ./conkySimpleForecast -d wind_deg_font} -- this is to display the appropriate compass character in ConkyWind.otf, which per my tweaks to the script shows the direction the wind is blowing TOWARDS
Based on lines 300 and 355 of the script, I guess the output is N/A when there is no wind.
In order to try to display png images for the compass points, I tried to make an additional tweak to the script by inserting
wind_deg_opp)
data=$(cat ${cache_path} | ${JQ} ".wind.deg" -r | xargs printf "%.f" $p)
data=$(wind_deg_to_textopp ${data})
;;
after line 205 (ie, after the definition for wind_deg). From terminal I opened the directory containing the script, then ran
bash ./conkySimpleForecast -d wind_deg_opp
. This command does display the correct "opposite" direction, so I know at least the script by itself does what I want.
But I am not sure how to get the appropriate compass icon image to be displayed from within the conky config.
I tried:
${execi 300 cp -f $HOME/Forecast_Images_2015-Openweather/$(execi 120 $HOME/conkystuff/conkySimpleForecast/conkySimpleForecast -d wind_deg_opp).png $HOME/.cache/sfwind.png}${image $HOME/.cache/sfwind.png -p 5,5 -s 32x32}
and
${image $HOME/Forecast_Images_2015-Openweather/$(execi 120 $HOME/conkystuff/conkySimpleForecast/conkySimpleForecast -d wind_deg_opp).png -p 5,5 -s 32x32}
Both are not generating any compass image in the conky. It probably is due to running the script nestled within the conky line, but I am not sure what the proper syntax should be.
PS. $HOME/Forecast_Images_2015-Openweather/ is the directory where I renumbered the 2015 Forecast images to be in line with openweather codes. I simply copied over the compass images from Accuweather conky script.
Offline
I tried to adapt accuweather Forecast_Images_2016 for Gis Weather.
https://i.postimg.cc/nXfc0rFm/accu2016.png
If you like, you can download it:
https://workupload.com/file/SKSu8K7YMHZFollow the installation instructions:
https://forums.bunsenlabs.org/viewtopic … 63#p131063
I did see this post.
Thanks for the Forecast2016 images for gisweather. I agree that VClouds is a nice set.
Offline