4

I've been strugling to get conky to show the weather, I just installed it and found out that yahoo discontinued the api url which was the one the conky theme was using (http://weather.yahooapis.com/forecastrss?w=1103816&u=c), I've tried changing the url to accuweather and openweather ones and nothing. I just don't understand how this works at all and I have no clue how to get it to work properly, here's the code:

##Weather
${image .jelly-weather-icons/conky_icons/circle2.png -s 190x190}
${texeci 1300 curl -s "http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRIC}#\&locCode\=$LOCCOD" -o #~/.cache/weather.xml}
${voffset -110}${offset 425}${font ITC Avant Garde Gothic Pro:bold:size=20}${execi 1300 grep #"yweather:condition" ~/.cache/weather.xml | grep -o "temp=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | #grep -o "[^\"]*"}${font ITC Avant Garde Gothic Pro:bold:size=8}${voffset -16}o${voffset 14}${font}#${color1}
${execi 1300 cp -f .weather-icons/$(grep "yweather:condition" ~/.cache/weather.xml | grep -o #"code=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*").png ~/.cache/weather.png}${image #~/.cache/weather.png -p 425,23 -s 35x35}
${offset 420}${voffset -105}${font ITC Avant Garde Gothic Pro:size=14} Sevilla

btw I found nothing on the internet that could help me out... thanks in advance :)

Edit1: Here is the api that the conky theme saves in the cache/weather.xml http://api.openweathermap.org/data/2.5/forecast?id=6361046&APPID=6be5e3a6e62680c28044791e8fc7b568 I'm slowly understanding how it works

Edit2: This is how the code looks now, I noticed I mistyped some # trying to comment the whole weather part. I just don't understand how conky reads xml (I don't know how to read xml myself but I suppose I can solve that with a few guides of xml :P)

##Weather
${image .jelly-weather-icons/conky_icons/circle2.png -s 190x190}
${texeci 1300 curl -s "http://api.openweathermap.org/data/2.5/forecast?id=6361046&APPID=6be5e3a6e62680c28044791e8fc7b568&units=metric" -o ~/.cache/weather.xml}
${voffset -110}${offset 425}${font ITC Avant Garde Gothic Pro:bold:size=20}${execi 1300 grep "weather:description" ~/.cache/weather.xml | grep -o "temp=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*"}${font ITC Avant Garde Gothic Pro:bold:size=8}${voffset -16}o${voffset 14}${font}${color1}
${execi 1300 cp -f .weather-icons/$(grep "yweather:condition" ~/.cache/weather.xml | grep -o "code=\"[^\"]*\"" | grep -o "\"[^\"]*\"" | grep -o "[^\"]*").png ~/.cache/weather.png}${image ~/.cache/weather.png -p 425,23 -s 35x35}
${offset 420}${voffset -105}${font ITC Avant Garde Gothic Pro:size=14} Sevilla

Edit3: So I finally got it working thanks to @WinEunuuchs2Unix and @steeldriver , this is how the code finally looks for anyone who wants to use it in their conky code:

##Weather

${voffset -80}${offset 435}${font ITC Avant Garde Gothic Pro:bold:size=20}${execi 1300 curl -s "http://api.openweathermap.org/data/2.5/forecast?id=6361046&APPID=6be5e3a6e62680c28044791e8fc7b568&units=metric" | jq -r '.list[0].main.temp' | awk '{printf("%.0f\n", $1)}'}${font ITC Avant Garde Gothic Pro:bold:size=8}${voffset -16}o${voffset 24}${font}${color1}
${execi 1300 cp -f .iconos/$(curl -s "http://api.openweathermap.org/data/2.5/forecast?id=6361046&APPID=6be5e3a6e62680c28044791e8fc7b568&units=metric" | jq -r '.list[0].weather[].icon').png ~/.cache/weather.png}${image ~/.cache/weather.png -p 425,20 -s 60x60}
${offset 420}${voffset -115}${font ITC Avant Garde Gothic Pro:bold:size=14} Sevilla

Basically what it does is read a json from the openweather url using curl, and with jq search for the values of .list[0].weather[].icon and .list[0].main.temp as for the temperature it outputs a value with 2 decimal digits which I cut out for personal preferences using awk '{printf("%.0f\n", $1)}' the rest of the code is just conky's way to understand where you want it and how you want it. If you want to use it for yourself just change Sevilla for your city, and change curl -s "...your location api url..." note that if you use a different site for your api url you will have to change jq to fit the new json data. Also note that you will have to create a folder with all the icons from this icon list or use your own icons but remember to use the same naming (01d.png, 02d.png, ...) and also don't forget to edit this ${execi 1300 cp -f .iconos/$(curl -s "http:/... and replace .iconos/ with the directory of your folder.

Here if you want to try out the conky theme

Wonky
  • 321
  • 1
  • 3
  • 12

5 Answers5

4

Edit June 7, 2020

I have conky on a 4K TV now so there is ample space to expand the height with weather information.

It is very important to select a mono spaced font that supports arrow signs for wind direction. I choose GE Inspira Mono 12 point but had to restore to Ubuntu 10.5 point afterwards:

#------------+
# Brightness |
#------------+
${color orange}${voffset 2}${hr 1}
${color1}${goto 5}Sun Rise: ${color green}${execpi 300 cat /usr/local/bin/.eyesome-sunrise} ${goto 175}${color1}Set: ${color green}${execpi 300 cat /usr/local/bin/.eyesome-sunset} ${alignr}${color1}Level: ${color green}${execpi 10 cat /sys/class/backlight/intel_backlight/brightness}
#------------+
# Weather    |
#------------+
${color orange}${voffset 2}${hr 1}
#${font GE Inspira Mono:size=12}${alignc}${color green}${execpi 300 curl wttr.in/Edmonton?T0 --silent --max-time 3}${font ubuntu:size=10.5}
${font Dejavu Sans Mono:size=12}${alignc}${color green}${execpi 300 curl wttr.in/Edmonton?T0 --silent --max-time 3}${font ubuntu:size=10.5}

This is what it looks like now:

conky weather.png

Yes it is unusually cold for 6 pm on June 7. Worse yet all the rain caused a 20 block power outage a couple hours ago! It was a mixed blessing because I got to install the 32 GB RAM upgrade I bought in March 2020 but was procrastinating on. System is snappier now!

NOTE: Sunrise and Sunset times are fake. I was testing a new function in eyesome today to override the daily automatic retrieval off the internet of Sun Times (aka Twilight times).


Original Answer

Weather is too much information to squeeze into my conky display which is already pretty full. So instead I put it in my terminal splash screen:

terminal splash screen.png

You can get the same information from the command line which you can call from conky:

$ curl wttr.in/Edmonton?0 --silent --max-time 3

Weather report: Edmonton

 \   /     Clear
  .-.      7..8 °C        

― ( ) ― → 6 km/h
`-’ 10 km
/ \ 0.0 mm

To get your city name for wttr.in see:


Display an image in conky

I saved a picture of today's weather from darksky.net and displayed it in conky with the ${image} command:

Weather in conky.png

The relevant conky commands are:

#------------+
# Brightness |
#------------+
${color orange}${voffset 2}${hr 1}
${color1}${goto 5}Rise: ${color green}${execpi 300 cat /usr/local/bin/.eyesome-sunrise} ${goto 155}${color1}Set: ${color green}${execpi 300 cat /usr/local/bin/.eyesome-sunset} ${alignr}${color1}Level: ${color green}${execpi 10 cat /sys/class/backlight/intel_backlight/brightness}

#------------+

Image |

#------------+ ${image /home/rick/Pictures/Weather.png -p 0,1080 -s 400x120}

  • I included the section just before for reference
  • Notice all the blank lines to make conky window taller to fit in the image
  • See: Variables in Conky for more details on ${image} command.
1

I was very inspired by this thread as I did not find any working Conky widget and went down to learn and create my own (based on code posted here).

Here's a widget that uses IP geolocation to identify (or guess) your rough position and display 5-day weather accordingly. Uses Big Data Cloud and Open Weather Maps APIs.

I hope it works for all of you. Simply download the file, save it to the ~/.conky directory and execute:

conky -c ~/.conky/Weather

Weather widget file:

conky.config = {
    use_xft = true,
    font = 'GE Inspira:size=16',
    xftalpha = 0.8,
    text_buffer_size = 2048,
    max_text_width = 0,
    override_utf8_locale = true,
    uppercase = false,
    no_buffers = true,
    short_units = true,
    format_human_readable = true,
update_interval = 1,
total_run_times = 0,

own_window = true,
own_window_transparent = false,
own_window_type = 'desktop',
own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
    own_window_argb_visual = true,
    own_window_argb_value = 128,
background = true,
use_spacer = 'none',

double_buffer = true,
minimum_width = 215, minimum_height = 215,

draw_shades = false,
default_shade_color = '#000000',

draw_outline = false,
default_outline_color = '#000000',

default_color = 'FFFFFF', 
color0 = 'FFFFFF',
color1 = 'FFA300',

draw_borders = false,
stippled_borders = 0,
border_inner_margin = 10,
border_outer_margin = 0,
border_width = 1,
draw_graph_borders = false,--no
alignment = 'top_left',

gap_x = 107,
gap_y = 220,

imlib_cache_size = 0,

};

conky.text = [[

#REFRESH LOCATION & WEATHER INFO CACHE ${execi 600 curl -so ~/.cache/WeatherLoc 'https://api.bigdatacloud.net/data/ip-geolocation?localityLanguage=en&key=3131602e55a644299e1372eaa28f3fe5'&& printf "https://api.openweathermap.org/data/2.5/onecall?lat=%s&lon=%s&exclude=minutely,hourly&APPID=a6f8bedf50667be2d3764422a37077d2&units=metric" $(jq -r '.location.latitude' ~/.cache/WeatherLoc) $(jq -r '.location.longitude' ~/.cache/WeatherLoc)| xargs curl -so ~/.cache/WeatherData}

#REFRESH ICON CACHE ${execi 600 sleep 2 && jq -r '.current.weather[0].icon' ~/.cache/WeatherData | xargs printf "http://openweathermap.org/img/wn/%s@2x.png" | xargs curl -so ~/.cache/WeatherNow.png}
${execi 600 sleep 2 && jq -r '.daily[0].weather[0].icon' ~/.cache/WeatherData | xargs printf "http://openweathermap.org/img/wn/%s@2x.png" | xargs curl -so ~/.cache/Weather0.png}
${execi 600 sleep 2 && jq -r '.daily[1].weather[0].icon' ~/.cache/WeatherData | xargs printf "http://openweathermap.org/img/wn/%s@2x.png" | xargs curl -so ~/.cache/Weather1.png}
${execi 600 sleep 2 && jq -r '.daily[2].weather[0].icon' ~/.cache/WeatherData | xargs printf "http://openweathermap.org/img/wn/%s@2x.png" | xargs curl -so ~/.cache/Weather2.png}
${execi 600 sleep 2 && jq -r '.daily[3].weather[0].icon' ~/.cache/WeatherData | xargs printf "http://openweathermap.org/img/wn/%s@2x.png" | xargs curl -so ~/.cache/Weather3.png}
${execi 600 sleep 2 && jq -r '.daily[4].weather[0].icon' ~/.cache/WeatherData | xargs printf "http://openweathermap.org/img/wn/%s@2x.png" | xargs curl -so ~/.cache/Weather4.png}

#WEATHER NOW ${voffset -40}${color1}${execi 1 jq -r '.location.city' ~/.cache/WeatherLoc} ${color0}${execi 1 jq -r '.current.temp' ~/.cache/WeatherData |awk '{print int($1+0.5)}'}° ${image ~/.cache/WeatherNow.png -s 70x70 -p 160,0}

#WEATHER TODAY ${color1}Today${goto 100}${color0}${execi 1 jq -r '.daily[0].temp.min' ~/.cache/WeatherData |awk '{print int($1+0.5)}'}°/ ${execi 1 jq -r '.daily[0].temp.max' ~/.cache/WeatherData |awk '{print int($1+0.5)}'}°${image ~/.cache/Weather0.png -s 30x30 -p 180,83}

#WEATHER +1 DAY ${color1}${execi 1 jq -r '.daily[1].dt' ~/.cache/WeatherData |awk ' {print "@" $1}' |xargs date +%a --date}${goto 100}${color0}${execi 1 jq -r '.daily[1].temp.min' ~/.cache/WeatherData |awk '{print int($1+0.5)}'}°/ ${execi 1 jq -r '.daily[1].temp.max' ~/.cache/WeatherData |awk '{print int($1+0.5)}'}°${image ~/.cache/Weather1.png -s 30x30 -p 180,108}

#WEATHER +2 DAYS ${color1}${execi 1 jq -r '.daily[2].dt' ~/.cache/WeatherData |awk ' {print "@" $1}' |xargs date +%a --date}${goto 100}${color0}${execi 1 jq -r '.daily[2].temp.min' ~/.cache/WeatherData |awk '{print int($1+0.5)}'}°/ ${execi 1 jq -r '.daily[2].temp.max' ~/.cache/WeatherData |awk '{print int($1+0.5)}'}°${image ~/.cache/Weather2.png -s 30x30 -p 180,133}

#WEATHER +3 DAYS ${color1}${execi 1 jq -r '.daily[3].dt' ~/.cache/WeatherData |awk ' {print "@" $1}' |xargs date +%a --date}${goto 100}${color0}${execi 1 jq -r '.daily[3].temp.min' ~/.cache/WeatherData |awk '{print int($1+0.5)}'}°/ ${execi 1 jq -r '.daily[3].temp.max' ~/.cache/WeatherData |awk '{print int($1+0.5)}'}°${image ~/.cache/Weather3.png -s 30x30 -p 180,158}

#WEATHER +4 DAYS ${color1}${execi 1 jq -r '.daily[4].dt' ~/.cache/WeatherData |awk ' {print "@" $1}' |xargs date +%a --date}${goto 100}${color0}${execi 1 jq -r '.daily[4].temp.min' ~/.cache/WeatherData |awk '{print int($1+0.5)}'}°/ ${execi 1 jq -r '.daily[4].temp.max' ~/.cache/WeatherData |awk '{print int($1+0.5)}'}°${image ~/.cache/Weather3.png -s 30x30 -p 180,183} ]];

Weather widget snapshot looks like :

enter image description here

muru
  • 207,228
0

Disclaimer: I don't remember where I got this.

I have a little script weather.sh

#!/bin/sh
#AccuWeather (r) RSS weather tool for conky
#
#USAGE: weather.sh <locationcode>
#
#(c) Michael Seiler 2007

METRIC=0 #Should be 0 or 1; 0 for F, 1 for C

if [ -z $1 ]; then
    echo
    echo "USAGE: weather.sh <locationcode>"
    echo
    exit 0;
fi

curl -s http://rss.accuweather.com/rss/liveweather_rss.asp\?metric\=${METRIC}\&locCode\=$1 | perl -ne 'if (/Currently/) {chomp;/\<title\>Currently: (.*)?\<\/title\>/; print "$1"; }'

Then in the .conkyrc you have

${exec [location of script]/weather.sh [zip code]}

The end result is

enter image description here

0

I made a shell script that uses wethr snap app. This app shows weather based on your location on a terminal.

$ wethr

Asunción, Paraguay: 31C ☀️

Currently Conky doesn't handle emojis very well, so I had to use pangoview to convert the text to an image.

I use it on conky with

${image /tmp/weather-1000.jpg -p 95,328}

Add also this line, to enable images reload in conky

imlib_cache_flush_interval=1500,

Here's the script

https://github.com/alefq/helper-scripts/blob/master/bin/weather.sh

#!/bin/bash
#
# requires wethr from snap store and pango1.0-tools
#
WFILE=/tmp/.weather-info-$UID
DEBUG=0

if [ -z $DISPLAY ]; then # probably running from crontab export DISPLAY=:0 fi

if [ $DEBUG -eq 0 ]; then /snap/bin/wethr > $WFILE 2>/dev/null else /snap/bin/wethr > $WFILE fi pango-view --background=#ffffff --font=onot -qo /tmp/weather-$UID.jpg $WFILE

Crontab update every 30 minutes

33 * * * * /opt/helper-scripts/bin/weather.sh

The final result

enter image description here

muru
  • 207,228
Awi
  • 688
0

I wrote a command line tool to create weather widgets in conky using data from the openweathermap API. You can make them as simple or as complex as you want. For example, to display Clouds: 22° updated every 20 minutes, use:

${execi 1200 echo "$(weather -d main): $(weather)" }

There are more options available. See here for more information.

jagrg
  • 101