You are not logged in.

#1 2018-09-30 04:08:20

New Member
Registered: 2018-09-29
Posts: 4

Arrows (and cardinals) for wind direction in Conky weather


After following the directions to get your API key sorted and your weather script working, here are some functions to have an arrow (or text) display the direction from which the wind is blowing (especially nice for cyclists). Edits to ~/.config/conky/scripts/

compare() {
    awk -v direction="$1" -v deg="$2" 'BEGIN {
        exit (direction '$3' deg) ? 0 : 1

cardinal_direction() {
    if compare $1 337.6 '>=' || compare $1 22.5 '<=';then
        arrow=$(printf '\xe2\x86\x93')
    elif compare $1 22.6 '>=' && compare $1 67.5 '<=';then
        arrow=$(printf '\xe2\x86\x99')
    elif compare $1 67.6 '>=' && compare $1 123.75 '<=';then
        arrow=$(printf '\xe2\x86\x90')
    elif compare $1 123.76 '>=' && compare $1 146.25 '<=';then
        arrow=$(printf '\xe2\x86\x96')
    elif compare $1 168.76 '>=' && compare $1 191.75 '<=';then
        arrow=$(printf '\xe2\x86\x91')
    elif compare $1 213.76 '>=' && compare $1 236.25 '<=';then
        arrow=$(printf '\xe2\x86\x97')
    elif compare $1 258.76 '>=' && compare $1 281.25 '<=';then
        arrow=$(printf '\xe2\x86\x92')
        arrow=$(printf '\xe2\x86\x98')

After we load our gathered weather values into an array around line 141 of, we can call our function with the wind direction as an argument to load our fancy variables:

cardinal_direction ${all[8]}

We now have two variables exposed for our script, $cardinal which holds a textual direction (N, NE, E, SE, S, SW, W, NW) and $arrow which will graphically stand in for those directions (the arrows suit my mental model of wind direction better).

For the arrows to display properly, we need a font that has all of the unicode directional arrows, e.g. DejaVu:

sudo apt-get fonts-dejavu

Our output for the above screenshot which uses the arrow for wind direction is coded like so:

printf "State of being:\${alignr}%s\nTemp:\${alignr}%s\nWind\${alignr} \${font dejavu sans:size=12}\${voffset -2}%s\${font}  at %s\nHumidity:\${alignr}%s\n" "$description" "$temperature" "$arrow" "$windspeed" "$humidity"

Note that we explicitly declare the font for the arrow alone and make it a bit larger for legibility, then use a vertical offset so that line of text remains in balance with the surrounding context.

I hope this is useful for someone.

Last edited by ethet (2018-10-05 20:04:36)


#2 2018-09-30 04:33:23

Resident Metalhead
From: New Zealand
Registered: 2015-09-29
Posts: 2,496

Re: Arrows (and cardinals) for wind direction in Conky weather

Man that looks really cool.

One of the ArchLabs dudes
Obssesive Metalhead and practiced beer drinker


Board footer

Powered by FluxBB