You are not logged in.

#901 2018-02-24 19:44:15

manuel-909
Member
Registered: 2017-10-09
Posts: 80

Re: Show us your conky

alpetjr , yes i have it backwards i fix it change colors too...
2018-02-24-14-37-58_scrot.th.png

Offline

#902 2018-02-24 20:02:42

manuel-909
Member
Registered: 2017-10-09
Posts: 80

Re: Show us your conky

unklar ths is a good link to start with sed:
http://sed.sourceforge.net/sed1line.txt

Last edited by manuel-909 (2018-02-24 20:03:32)

Offline

#903 2018-02-25 10:23:39

unklar
Member
Registered: 2015-10-31
Posts: 950

Re: Show us your conky

^Thanks Indian, that's what it does.  wink

Thank you manuel-909.
Can you explain this comment of damo to me in the script?

...remove any '$' chars; add conky var code to beginning of line

Offline

#904 2018-02-25 21:35:09

manuel-909
Member
Registered: 2017-10-09
Posts: 80

Re: Show us your conky

no really if you type conky var code in terminal start a conky i remove goto don't needed.

if (( $? == 0 ));then
    # Get 6 lines; trim to 50 chars; remove any '$' chars; add conky var code to beginning of line
curl -s "$URL" | grep "<title" | grep -o -P '(?<=CDATA\[).*(?=\]\])'| tail -n +1 | head -n 10 | cut -c 1-50  | sed 's/^/        /' | sed 's|[<>$,]||g'

else
    echo "\No internet connection"
    echo "\Forum feed unavailable"

this inside conky give de same:

};
conky.text = [[
${rss https://forums.bunsenlabs.org/extern.ph … d&type=rss 1 item_titles 10}

2018-02-25-16-28-54_scrot.th.png

Offline

#905 2018-02-28 18:34:17

unklar
Member
Registered: 2015-10-31
Posts: 950

Re: Show us your conky

^ Thank you, manuel-909   smile

Offline

#906 2018-03-03 05:37:07

manuel-909
Member
Registered: 2017-10-09
Posts: 80

Re: Show us your conky

your welcome unklar  wink

Offline

#907 2018-03-06 10:29:24

unklar
Member
Registered: 2015-10-31
Posts: 950

Re: Show us your conky

The Conky published here is supposed to be my Respect for the 20th Chemnitzer Linux Days this weekend.
Actually, there are two conky configurations that go back to @damo.

conky1.10
the weather
.conkyrc

--März 2018 unklar
conky.config = {
-- Hintergrund
	background = false,

-- Schrift
	use_xft = true,
	font = 'terminus:size=8',--Schriftart
	xftalpha = 0.2,

-- Aktualisierung und Fenster von Conky
	update_interval = 1,--in Sekunden
	total_run_times = 0,--Gesamtzahl der updates bis conky beendet wird; bei 0 laeuft endlos
	own_window = true,--eigenes Fenster
	own_window_type = 'normal',--Art des Fenster(normal=Standard,desktop=keine Fensterdekoration,panel=überdeckt das dm-panel,dock=immer oben,Sticky auf allen Fenstern)
--               override  #wird nicht durch den Fenstermanager kontrolliert
	own_window_transparent = true,
	own_window_hints = 'undecorated,below,skip_taskbar,skip_pager',--sticky,
	own_window_class = 'conky',--damit conky bei bestimmten Fenstermanagern nicht verschwindet
	own_window_argb_visual = true,
--own_window_argb_value 0 (durchsichtig)-255 (undurchsichtig)
--own_window_colour 000000  #wenn kein transparenter Hintergrund>Wahl der Hintergrundfarbe in hexadezimal(zB ffffff)
--own_window_title  damo-Weather     #manuelles setzen des Fensternamen, Standard ist <hostname> -conky

-- Buffers
	double_buffer = true,--bei eigenem Fenster, damit X-Server-Buffer nicht zu gross und kein Flackern auftritt
	no_buffers = true,--damit der Arbeitsspeicher nicht überlaeuft

-- Aktualisierungsfrequenz von Prozessor und Netz
	cpu_avg_samples = 2,
	net_avg_samples = 2,

-- Rahmen
	draw_shades = false,--Schatten um Text
	draw_outline = false,
	draw_borders = false,--Rahmen um Text
	draw_graph_borders = false,--Rahmen um Graphen
	border_inner_margin = 0,--Rahmenabstand in Pixeln
	border_outer_margin = 0,--dito
	stippled_borders = 0,--Abstaende gestrichelter Rahmen in Pixeln

-- Farben
	default_color = 'white',--Ändern der Standardfarbe bei dunklen Hintergründen
	default_color = 'black',--Ändern der Standardfarbe bei hellen Hintergründen
	color0 = '#ffffff',--Beispiele
	color1 = '#b22222',


-- Alignment              #Ausrichtung auf dem Bildschirm 
--alignment top_left      #tl
--alignment top_right     #tr
--alignment top_middle    #tm
--alignment bottom_left   #bl
--alignment bottom_right  #br
--alignment bottom_middle #bm
--alignment middle_left   #ml
--alignment middle_right  #mr
--alignment middle_middle #mm
	alignment = 'bottom_right',


	uppercase = false,--Grossbuchstaben
	use_spacer = 'none',--left,right or none  nur mit Mono-Schriften, setzt Abstaende, damit das eine Objekt nicht das Andere verschiebt
	text_buffer_size = 4096,--die Zahl bestimmt, dass conky nicht abgeschnitten wird
	imlib_cache_size = 0,
	override_utf8_locale = true,--damit Umlaute und Sonderzeichen korrekt erscheinen

-- Fenstergrösse
	minimum_width = 300, minimum_height = 220,--minimale Fenstergrösse in Pixeln
--maximum_width 350       #maximale Breite in Pixeln
	gap_x = 20,--Einstellung wenn conky oben
	gap_y = 200,--Einstellung wenn conky unten

----Lua--#
	lua_load = '~/damo-weather/lua1-weather.lua',
	lua_draw_hook_pre = 'conky_main',

};

conky.text = [[
${execpi 300 bash /home/unklarer/damo-weather/lua-weather.sh Lichtenstein,DE}\
${color0}${voffset 180} #${alignc}${font monofur bold:size=12}${time %H:%M}
#${alignc}${font monofur bold:size=8}${time %a.%d. %b}
${alignc -30}${font monofur bold:size=7}Lichtenstein${font}
]];

conkyrc in the rainmeter-style

-- Elegance-beam conky by damo, July 2017
-- Conky v1.10

conky.config = {
	alignment = 'top_right',
	background = false,
	border_inner_margin = 15,
	border_width = 5,
	default_color = 'ffffff',  --ffffff # grey 5f5f5f 3F3F3F 183149 3B3B3B 26211F
	double_buffer = true,
	draw_borders = false,
	draw_graph_borders = false,
	draw_outline = false,
	draw_shades = false,
	gap_x = 25,
	gap_y = 25,
	maximum_width = 320,
	double_buffer = true,
	override_utf8_locale = true,
    own_window = true,
    own_window_class = 'Conky',
    own_window_type = 'normal',
	own_window_transparent = true,
	own_window_hints = 'undecorated,below,skip_taskbar,skip_pager',   --sticky',
	own_window_argb_visual = true,
--	own_window_argb_value = 150,
	text_buffer_size = 8000,
	total_run_times = 0,
	update_interval = 1,
	uppercase = false,
	use_xft = true,
	xftalpha = 1,
	short_units = false,
	font = 'AvantGarde LT ExtraLight:pixelsize=16',
	color1 = '678b8b',
	color2 = '284f63',
	color3 = 'b72e3f',
	color4 = '668989',
	color5 = 'dae1e3',
	color6 = '5d8185',
	color7 = '4f727b',
};

conky.text = [[
${color}${font AvantGarde LT ExtraLight:pixelsize=150}${alignr}${time %H}
${voffset -65}${alignr}${color3}${time %M}
${voffset -90}${color}${font AvantGarde LT ExtraLight:pixelsize=20}${alignr}${time %A}  |  ${alignr}${time %d.%B %Y}
${voffset 20}${color}${font}ram ${alignr}${mem} / ${memmax}
cpu ${alignr}${cpu cpu0}%
cpu temp ${alignr}${color}${hwmon 1 temp 2} °C
GPU ${alignr}${hwmon 2 temp 1} °C
fs  ${alignr}${fs_used_perc /}% / ${fs_size /}
${voffset 30}${alignr}${kernel}
${hr}
${font Birdman}Siduction  ${alignr} W E A T H E R 













#${goto 40}${font liberation mono:size=9}${execi 600 curl 'wttr.in/leipzig?q?0?T'}${font}
${hr}
${font Birdman}Linux News DE  ${alignr}F E E D
${font AvantGarde LT ExtraLight:pixelsize=14}${rss http://feeds.feedburner.com/linuxnewsde/ 15 item_titles 4 2}
#${rss https://forum.siduction.org/index.php?type=rss&action=feed/ 15 item_titles 3 2}
#${color}${font AvantGarde LT ExtraLight:pixelsize=14}${voffset 2}${execi 300 $HOME/.conky/damo/elegance-atomfeed.sh}
${hr}
]];

Offline

#908 2018-03-06 23:05:36

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: Show us your conky

^I just saw the posts in the March screenshots thread and the second conky seems to work ok for me. I'm wondering what's the difference between

${color grey}TEMP: $alignr $color ${acpitemp}°C

and

${color grey}CPU: $alignr $color ${hwmon 1 temp 2}°C
${color grey}GPU: $alignr $color ${hwmon 2 temp 1}°C

Interestingly I had in the script {hwmon 0 temp 1} before, but changed it to acpi. It's very close to the GPU temperature, but not exactly the same.

The first conky somehow did not work for me, it just printed a word (Lichtenstein).

Offline

#909 2018-03-07 07:47:21

ragamatrix
Member
Registered: 2015-10-04
Posts: 411

Re: Show us your conky

unklar wrote:

The Conky published here is supposed to be my Respect for the 20th Chemnitzer Linux Days this weekend.
Actually, there are two conky configurations that go back to @damo.

conky1.10
the weather
.conkyrc

--März 2018 unklar
conky.config = {
-- Hintergrund
	background = false,

-- Schrift
	use_xft = true,
	font = 'terminus:size=8',--Schriftart
	xftalpha = 0.2,

-- Aktualisierung und Fenster von Conky
	update_interval = 1,--in Sekunden
	total_run_times = 0,--Gesamtzahl der updates bis conky beendet wird; bei 0 laeuft endlos
	own_window = true,--eigenes Fenster
	own_window_type = 'normal',--Art des Fenster(normal=Standard,desktop=keine Fensterdekoration,panel=überdeckt das dm-panel,dock=immer oben,Sticky auf allen Fenstern)
--               override  #wird nicht durch den Fenstermanager kontrolliert
	own_window_transparent = true,
	own_window_hints = 'undecorated,below,skip_taskbar,skip_pager',--sticky,
	own_window_class = 'conky',--damit conky bei bestimmten Fenstermanagern nicht verschwindet
	own_window_argb_visual = true,
--own_window_argb_value 0 (durchsichtig)-255 (undurchsichtig)
--own_window_colour 000000  #wenn kein transparenter Hintergrund>Wahl der Hintergrundfarbe in hexadezimal(zB ffffff)
--own_window_title  damo-Weather     #manuelles setzen des Fensternamen, Standard ist <hostname> -conky

-- Buffers
	double_buffer = true,--bei eigenem Fenster, damit X-Server-Buffer nicht zu gross und kein Flackern auftritt
	no_buffers = true,--damit der Arbeitsspeicher nicht überlaeuft

-- Aktualisierungsfrequenz von Prozessor und Netz
	cpu_avg_samples = 2,
	net_avg_samples = 2,

-- Rahmen
	draw_shades = false,--Schatten um Text
	draw_outline = false,
	draw_borders = false,--Rahmen um Text
	draw_graph_borders = false,--Rahmen um Graphen
	border_inner_margin = 0,--Rahmenabstand in Pixeln
	border_outer_margin = 0,--dito
	stippled_borders = 0,--Abstaende gestrichelter Rahmen in Pixeln

-- Farben
	default_color = 'white',--Ändern der Standardfarbe bei dunklen Hintergründen
	default_color = 'black',--Ändern der Standardfarbe bei hellen Hintergründen
	color0 = '#ffffff',--Beispiele
	color1 = '#b22222',


-- Alignment              #Ausrichtung auf dem Bildschirm 
--alignment top_left      #tl
--alignment top_right     #tr
--alignment top_middle    #tm
--alignment bottom_left   #bl
--alignment bottom_right  #br
--alignment bottom_middle #bm
--alignment middle_left   #ml
--alignment middle_right  #mr
--alignment middle_middle #mm
	alignment = 'bottom_right',


	uppercase = false,--Grossbuchstaben
	use_spacer = 'none',--left,right or none  nur mit Mono-Schriften, setzt Abstaende, damit das eine Objekt nicht das Andere verschiebt
	text_buffer_size = 4096,--die Zahl bestimmt, dass conky nicht abgeschnitten wird
	imlib_cache_size = 0,
	override_utf8_locale = true,--damit Umlaute und Sonderzeichen korrekt erscheinen

-- Fenstergrösse
	minimum_width = 300, minimum_height = 220,--minimale Fenstergrösse in Pixeln
--maximum_width 350       #maximale Breite in Pixeln
	gap_x = 20,--Einstellung wenn conky oben
	gap_y = 200,--Einstellung wenn conky unten

----Lua--#
	lua_load = '~/damo-weather/lua1-weather.lua',
	lua_draw_hook_pre = 'conky_main',

};

conky.text = [[
${execpi 300 bash /home/unklarer/damo-weather/lua-weather.sh Lichtenstein,DE}\
${color0}${voffset 180} #${alignc}${font monofur bold:size=12}${time %H:%M}
#${alignc}${font monofur bold:size=8}${time %a.%d. %b}
${alignc -30}${font monofur bold:size=7}Lichtenstein${font}
]];

conkyrc in the rainmeter-style

-- Elegance-beam conky by damo, July 2017
-- Conky v1.10

conky.config = {
	alignment = 'top_right',
	background = false,
	border_inner_margin = 15,
	border_width = 5,
	default_color = 'ffffff',  --ffffff # grey 5f5f5f 3F3F3F 183149 3B3B3B 26211F
	double_buffer = true,
	draw_borders = false,
	draw_graph_borders = false,
	draw_outline = false,
	draw_shades = false,
	gap_x = 25,
	gap_y = 25,
	maximum_width = 320,
	double_buffer = true,
	override_utf8_locale = true,
    own_window = true,
    own_window_class = 'Conky',
    own_window_type = 'normal',
	own_window_transparent = true,
	own_window_hints = 'undecorated,below,skip_taskbar,skip_pager',   --sticky',
	own_window_argb_visual = true,
--	own_window_argb_value = 150,
	text_buffer_size = 8000,
	total_run_times = 0,
	update_interval = 1,
	uppercase = false,
	use_xft = true,
	xftalpha = 1,
	short_units = false,
	font = 'AvantGarde LT ExtraLight:pixelsize=16',
	color1 = '678b8b',
	color2 = '284f63',
	color3 = 'b72e3f',
	color4 = '668989',
	color5 = 'dae1e3',
	color6 = '5d8185',
	color7 = '4f727b',
};

conky.text = [[
${color}${font AvantGarde LT ExtraLight:pixelsize=150}${alignr}${time %H}
${voffset -65}${alignr}${color3}${time %M}
${voffset -90}${color}${font AvantGarde LT ExtraLight:pixelsize=20}${alignr}${time %A}  |  ${alignr}${time %d.%B %Y}
${voffset 20}${color}${font}ram ${alignr}${mem} / ${memmax}
cpu ${alignr}${cpu cpu0}%
cpu temp ${alignr}${color}${hwmon 1 temp 2} °C
GPU ${alignr}${hwmon 2 temp 1} °C
fs  ${alignr}${fs_used_perc /}% / ${fs_size /}
${voffset 30}${alignr}${kernel}
${hr}
${font Birdman}Siduction  ${alignr} W E A T H E R 













#${goto 40}${font liberation mono:size=9}${execi 600 curl 'wttr.in/leipzig?q?0?T'}${font}
${hr}
${font Birdman}Linux News DE  ${alignr}F E E D
${font AvantGarde LT ExtraLight:pixelsize=14}${rss http://feeds.feedburner.com/linuxnewsde/ 15 item_titles 4 2}
#${rss https://forum.siduction.org/index.php?type=rss&action=feed/ 15 item_titles 3 2}
#${color}${font AvantGarde LT ExtraLight:pixelsize=14}${voffset 2}${execi 300 $HOME/.conky/damo/elegance-atomfeed.sh}
${hr}
]];

Really good news !
Your config in the screenshots thread is beautifull, can you post us the lua config with the "rose" inside the "circle" please ? I know I'm lazy x)... Im Voraus Vielen Dank wink
EDIT:
oops I speak too fast, I've got these lua errors because of the wind I think the error appears when there is no wind ... :

conky: desktop window (dc) is root window
conky: window type - normal
conky: drawing to created window (0x2800002)
conky: drawing to double buffer
conky: llua_do_call: function conky_main execution failed: /home/raphix/.config/conky/scripts/lua-weather.lua:81: attempt to perform arithmetic on a nil value
/home/raphix/.config/conky/scripts/lua-weather.sh: ligne 110 : printf: null: nombre non valable
conky: llua_do_call: function conky_main execution failed: /home/raphix/.config/conky/scripts/lua-weather.lua:81: attempt to perform arithmetic on a nil value
conky: llua_do_call: function conky_main execution failed: /home/raphix/.config/conky/scripts/lua-weather.lua:81: attempt to perform arithmetic on a nil value
conky: llua_do_call: function conky_main execution failed: /home/raphix/.config/conky/scripts/lua-weather.lua:81: attempt to perform arithmetic on a nil value
conky: llua_do_call: function conky_main execution failed: /home/raphix/.config/conky/scripts/lua-weather.lua:81: attempt to perform arithmetic on a nil value
conky: llua_do_call: function conky_main execution failed: /home/raphix/.config/conky/scripts/lua-weather.lua:81: attempt to perform arithmetic on a nil value
conky: llua_do_call: function conky_main execution failed: /home/raphix/.config/conky/scripts/lua-weather.lua:81: attempt to perform arithmetic on a nil value
conky: llua_do_call: function conky_main execution failed: /home/raphix/.config/conky/scripts/lua-weather.lua:81: attempt to perform arithmetic on a nil value
^[[Aconky: llua_do_call: function conky_main execution failed: /home/raphix/.config/conky/scripts/lua-weather.lua:81: attempt to perform arithmetic on a nil value
conky: llua_do_call: function conky_main execution failed: /home/raphix/.config/conky/scripts/lua-weather.lua:81: attempt to perform arithmetic on a nil value

Last edited by ragamatrix (2018-03-07 08:27:07)

Offline

#910 2018-03-07 10:39:21

unklar
Member
Registered: 2015-10-31
Posts: 950

Re: Show us your conky

martix wrote:

^I just saw the posts in the March screenshots thread and the second conky seems to work ok for me. I'm wondering what's the difference between

..${acpitemp}°C
...
${hwmon 1 temp 2}°C

Use the command

sensors -u
...

thinkpad-isa-0000
Adapter: ISA adapter

I'm not sure, but acpitemp is a module on ThinkPad and only works there. Sorry, only in Germanneutral

Sector11 documented this years ago.

martix wrote:

The first conky somehow did not work for me, it just printed a word (Lichtenstein).

^
You must also use the two Lua scripts from damo. Follow my links or what I write then ragamatrix.

Offline

#911 2018-03-07 11:22:45

unklar
Member
Registered: 2015-10-31
Posts: 950

Re: Show us your conky

ragamatrix wrote:

Really good news !

Hello, my friend  cool

Yesterday I tried to document everything here, because the configuration might be used as a presentation in Chemnitz.

Please use deepl.com/translator
If you have any questions, I'm here for you.  smile

I haven't gotten to testing myself yet. I don't have your lua mistake with the wind.
In the meantime, in my opinion there is still an error with the wind, because no wind is always displayed.
I tested the cities of Leipzig, Chemnitz, Lichtenstein, Glasgow and damo's screenshot Newcastle upon Tyne.
The wind output is always 0.0 kn.

I think I'm riding a dead horse here with an openweathermap. @damo has been absent for some time and we can't ask him.
@loutch asked for Teo's 2b_wunderground_API in this thread. Maybe we should tackle this, even though I don't know anything about LUA. Adjusting the paths to be used
would have to work out of the box.   devil


There's no point in looking beautiful  lol
Apart from that, the conky1.10 causes a large / permanent CPU load. I have already set the update_interval to 2 sec. and it has gone down about halfway. Not satisfactory to me. Maybe I should also move the tmp from the /home to /...

Offline

#912 2018-03-07 11:24:44

ragamatrix
Member
Registered: 2015-10-04
Posts: 411

Re: Show us your conky

@unklar
now there is a little bit wind so the script works... I've done the modification with the rose at the center:
2018-03-07-12-23-18_scrot.th.png

Offline

#913 2018-03-07 11:31:55

unklar
Member
Registered: 2015-10-31
Posts: 950

Re: Show us your conky

^ OMG, since where I have to test Horgen...   devil

Offline

#914 2018-03-07 11:38:32

unklar
Member
Registered: 2015-10-31
Posts: 950

Re: Show us your conky

270
0,0 kn
0653
1820
0,0
Horgen
light rain

Then you'll have to show me your variation...   tongue

${execpi 600 bash /home/unklarer/damo-weather/lua-weather.sh Horgen,CH}\
#
# If $place is not set, then the script attempts to get a geolocation from the IP address.

place="$1"              # Get $place from script parameter.
place="7286109"   # Uncomment and add name or id. NB If the name has spaces, then you must use the id.

# Choose fahrenheit/Imperial or Celcius/metric:
#metric='imperial'
metric='metric'

# data file
datafile="/home/unklarer/tmp/weather.txt"

Last edited by unklar (2018-03-07 11:46:50)

Offline

#915 2018-03-07 21:08:43

ragamatrix
Member
Registered: 2015-10-04
Posts: 411

Re: Show us your conky

Thanks unklar, I don't know why sometimes mine fails... I'm sure great lua players will tell me the reason wink I'm patient. Geduld Patience smile

Offline

#916 2018-03-07 21:22:35

unklar
Member
Registered: 2015-10-31
Posts: 950

Re: Show us your conky

Je ne comprends pas...
Mais pouvez-vous me dire si vous travaillez pour HORGEN avec les mêmes paramètres?   ops

et, quel est le paramètre auquel vous faites référence? C'est celui de la ligne 362-376?

function draw_wind_rose()
    draw_marks(cr,xW,yW,radiusW)
    draw_WindArrow(cr,xW,yW,50,direction,radiusW-8)
    draw_NESW(cr,xW,yW,radiusW,10)
    
--  print windspeed
    local fontface="Dustismo"
    local r,g,b,a = 1,1,1,0.6
    cairo_set_source_rgba (cr,r,g,b,a)
    cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
    cairo_set_font_size (cr,17)
    local xt,yt = position_text(cr,windS,xW,yW,2)
    cairo_move_to (cr,xt,yt)
    cairo_show_text (cr,windS)
    cairo_stroke (cr)

Offline

#917 2018-03-08 06:22:39

manuel-909
Member
Registered: 2017-10-09
Posts: 80

Re: Show us your conky

2018-03-08-01-19-50_scrot.th.png

Offline

#918 2018-03-08 11:21:26

unklar
Member
Registered: 2015-10-31
Posts: 950

Re: Show us your conky

I think I found the mistake. In my opinion, this is due to the internal conversion into nodes. I don't know why damo took that unit.
Specifically, it is about these lines 99 - 124 of the script.

        longitude=$(printf '%06.1f' ${all[0]})                <--Zeile 99
        latitude=$(printf '%+.1f' ${all[1]})                  <--Zeile 100
        condition="${all[2]}"
        temperature=$(printf '%+.1f%s' ${all[3]} $scaleT)
        pressure=$(printf '%.f %s' ${all[4]} mb)
        temperature_min=$(printf '%+.1f%s' ${all[5]} $scaleT)
        temperature_max=$(printf '%+.1f%s' ${all[6]} $scaleT)
        cloud_cover=$(printf '%d%s' ${all[9]} %)
        sunrise=$(date -d @${all[10]} +"%R")
        sunset=$(date -d @${all[11]} +"%R")
        description="$weather_desc"
        winddir=$(printf '%3.f%s' ${all[8]} °)
        
        winddir=${all[8]}
        echo ${winddir%.*} > "$datafile"
        windspeed=$(echo ${all[7]}*1.9 | bc)
        windspeed=$(printf '%01.1f %s' "$windspeed" "kn")     <==Zeile 115  
        echo "$windspeed" >> "$datafile"
        echo "$sunrise" | sed 's/://' >> "$datafile"
        echo "$sunset" | sed 's/://'>> "$datafile"
        temp_degrees=$(printf '%.1f' ${all[3]})
        echo "$temp_degrees" >> "$datafile"
        echo "$city" >> "$datafile" 
        echo "$description" >> "$datafile"

    else

The error messages in the terminal always say:"... invalid number".

/home/unklarer/damo-weather/lua-weather.sh: Zeile 99: printf: 12.92: Ungültige Zahl.<---das ist longitude
/home/unklarer/damo-weather/lua-weather.sh: Zeile 100: printf: 50.83: Ungültige Zahl.<--das ist latitude
/home/unklarer/damo-weather/lua-weather.sh: Zeile 115: printf: 15.5: Ungültige Zahl.<===!das ist der windspeed

For windspeed, this concerns this one and I don't know what needs to be changed:

        windspeed=$(printf '%01.1f %s' "$windspeed" "kn")     <==Zeile 115 

longtitude 12.92 and latitude 50.83 checked with the aunt Google, Chemnitz results.

Can a Script Professional Help?   smile

The whole script:

#!/bin/bash
#
## lua-weather.sh by <damo> July 2016
## Adapted from bunsenweather.sh, which was based on ideas from 
## weatherbang.sh version 1.0, 2013 by Ryan Fantus
##
## Requires:
##          'jq' (sudo apt-get install jq);
##          API Key from http://openweathermap.org/api
##
## USAGE: Call this script from Conky with ( replace "<t>" with the update interval)
##          ${execpi <t> /path/to/lua-weather.sh [location]}


#### User configurables:  ##############################################

# Get API KEY by registering for one at http://openweathermap.org/api
api="cbcdd9a40999d5d68afc55145f756764"

# Either set the location manually here, or by passing it as a script parameter in the Conky.
# "yourlocation" must be a name (which doesn't have spaces), or a numeric id.
#
# id's can be obtained from http://bulk.openweathermap.org/sample/city.list.json.gz
# Download and extract the json file, then simply search for an id with grep. 
#   For example:   grep "New York" city.list.json
#
# If $place is not set, then the script attempts to get a geolocation from the IP address.

place="$1"              # Get $place from script parameter.
place="2940132"   # Uncomment and add name or id. NB If the name has spaces, then you must use the id.

# Choose fahrenheit/Imperial or Celcius/metric:
#metric='imperial'
metric='metric'

# data file
datafile="/home/unklarer/tmp/weather.txt"

#########################################################################
connectiontest() {
    local -i i attempts=${1-0}
    for (( i=0; i < attempts || attempts == 0; i++ )); do
        if wget -O - 'http://ftp.debian.org/debian/README' &> /dev/null; then
            return 0
        fi
        if (( i == attempts - 1 )); then # if last attempt
            return 1
        fi
    done
}

placeholder() {
    if (( $1 == 1 )) &>/dev/null;then
        echo "No internet connection"
        echo "Weather information unavailable"
    else
        echo "No API key"
        echo "Weather information unavailable"
    fi
}

if [[ $metric == metric ]] &>/dev/null;then
    scaleT="°C"
    scaleV="kn"
else
    scaleT="°F"
    scaleV="mph"
fi

if [[ -z "$api" ]] &>/dev/null;then
    placeholder 0 && exit 1
else
    connectiontest 10
    
    # If latlong is preferred then don't set a value for $place
    if (( $? == 0 )) &>/dev/null;then
        if [[ -z $place ]] &>/dev/null;then
            # Geolocate IP:
            ipinfo=$(curl -s ipinfo.io)
            latlong=$(echo "$ipinfo" | jq -r '.loc')
            # Parse the latitude and longitude
            lat=${latlong%,*}
            long=${latlong#*,}
            location="lat=$lat&lon=$long"
        else
            # check if numeric id, or placename is being used
            [[ ${place##*[!0-9]*} ]] &>/dev/null && location="id=$place" || location="q=$place"
        fi

        # get json data from openweathermap:
        weather=$(curl -s http://api.openweathermap.org/data/2.5/weather\?APPID=$api\&"$location"\&units=$metric)
        city=$(echo "$weather" | jq -r '.name') # In case location has spaces in the name
        weather_desc=$(echo "$weather" | jq -r '.weather[0].description')   # In case description has spaces in the name

        # load values into array:
        all=($(echo "$weather" | jq -r '.coord.lon,.coord.lat,.weather[0].main,.main.temp,.main.pressure,.main.temp_min,.main.temp_max,.wind.speed,.wind.deg,.clouds.all,.sys.sunrise,.sys.sunset'))
        #                   ARRAY INDEX  0          1          2                3          4              5              6              7           8         9           10           11

        longitude=$(printf '%06.1f' ${all[0]})
        latitude=$(printf '%+.1f' ${all[1]})
        condition="${all[2]}"
        temperature=$(printf '%+.1f%s' ${all[3]} $scaleT)
        pressure=$(printf '%.f %s' ${all[4]} mb)
        temperature_min=$(printf '%+.1f%s' ${all[5]} $scaleT)
        temperature_max=$(printf '%+.1f%s' ${all[6]} $scaleT)
        cloud_cover=$(printf '%d%s' ${all[9]} %)
        sunrise=$(date -d @${all[10]} +"%R")
        sunset=$(date -d @${all[11]} +"%R")
        description="$weather_desc"
        winddir=$(printf '%3.f%s' ${all[8]} °)
        
        winddir=${all[8]}
        echo ${winddir%.*} > "$datafile"
        windspeed=$(echo ${all[7]}*1.9 | bc)
        windspeed=$(printf '%01.1f %s' "$windspeed" "kn")
        echo "$windspeed" >> "$datafile"
        echo "$sunrise" | sed 's/://' >> "$datafile"
        echo "$sunset" | sed 's/://'>> "$datafile"
        temp_degrees=$(printf '%.1f' ${all[3]})
        echo "$temp_degrees" >> "$datafile"
        echo "$city" >> "$datafile" 
        echo "$description" >> "$datafile"

    else
        placeholder 1
    fi
fi

exit 

Offline

#919 2018-03-08 12:17:36

manuel-909
Member
Registered: 2017-10-09
Posts: 80

Re: Show us your conky

for windspeed=$(printf '%01.1f %s' "$windspeed" "kn") change it to
windspeed=$(printf '%.1f %s' ${all[7]} $scaleV) to get mph.....

Offline

#920 2018-03-08 13:21:07

unklar
Member
Registered: 2015-10-31
Posts: 950

Re: Show us your conky

^ Thank you manuel-909.
That doesn help. Here is metric and not imperial   wink

Last edited by unklar (2018-03-08 13:23:56)

Offline

#921 2018-03-08 13:55:29

martix
Kim Jong-un Stunt Double
Registered: 2016-02-19
Posts: 1,267

Re: Show us your conky

unklar wrote:

I'm not sure, but acpitemp is a module on ThinkPad and only works there. Sorry, only in Germanneutral

I see, thank you for the hint.

Meanwhile I got that nice conky working (showing the wind in the middle and the state of the sun - really cool). I was just wondering:

datafile="/home/unklarer/tmp/weather.txt"

Is this required for that conky? I'm asking this because there was no such line in damo's original script and it is not there in the #BĹ default script either.

Offline

#922 2018-03-08 14:50:54

ragamatrix
Member
Registered: 2015-10-04
Posts: 411

Re: Show us your conky

unklar wrote:

Je ne comprends pas...
Mais pouvez-vous me dire si vous travaillez pour HORGEN avec les mêmes paramètres?   ops

et, quel est le paramètre auquel vous faites référence? C'est celui de la ligne 362-376?

function draw_wind_rose()
    draw_marks(cr,xW,yW,radiusW)
    draw_WindArrow(cr,xW,yW,50,direction,radiusW-8)
    draw_NESW(cr,xW,yW,radiusW,10)
    
--  print windspeed
    local fontface="Dustismo"
    local r,g,b,a = 1,1,1,0.6
    cairo_set_source_rgba (cr,r,g,b,a)
    cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
    cairo_set_font_size (cr,17)
    local xt,yt = position_text(cr,windS,xW,yW,2)
    cairo_move_to (cr,xt,yt)
    cairo_show_text (cr,windS)
    cairo_stroke (cr)

hi,
the script fails at these lines because of this (for me):

conky: llua_do_call: function conky_main execution failed: /home/raphix/.config/conky/scripts/lua-weather.lua:81: attempt to perform arithmetic on a nil value
/home/raphix/.config/conky/scripts/lua-weather.sh: ligne 110 : printf: null: nombre non valable

@manuel-909 can you post please your conky config to show how you display the next 2 days forecast ? (me=lua dummy) thx smile

Offline

#923 2018-03-08 18:16:04

unklar
Member
Registered: 2015-10-31
Posts: 950

Re: Show us your conky

martix wrote:
datafile="/home/unklarer/tmp/weather.txt"

Is this required for that conky? I'm asking this because there was no such line in damo's original script and it is not there in the #BĹ default script either.

^but, yes, it's contained in damo's script. wink
Take a good look again, the script has to write its values for Conky somewhere, so that he can read it.

Offline

#924 2018-03-08 18:18:36

unklar
Member
Registered: 2015-10-31
Posts: 950

Re: Show us your conky

ragamatrix wrote:

hi,
the script fails at these lines because of this (for me):


I didn't want to see your error message for the third time  big_smile ,  i wanted to see this one from you
https://forums.bunsenlabs.org/viewtopic … 879#p68879

Offline

#925 2018-03-08 20:25:49

manuel-909
Member
Registered: 2017-10-09
Posts: 80

Re: Show us your conky

here is regamatrix:
i'm using other script to display the day's...
for this to work you need to create a foder name it.
inside the folder create another foder name it scripts.
inside the folder create one more name it cache...
box.lua, launcher.lua , conkyweather , lua-weather.lua , lua-weather.sh , settings.lua
add lua's inside scripts.
add autostart.sh , conkyrc , inside main folder (remember to change the path's)

conkyrc:

conky.config = {
--Use XFT?
	use_xft = true,
	font = 'CaviarDreams:bold:size=10',
	xftalpha = 0,
	text_buffer_size = 2048,
	max_text_width = 0,
	override_utf8_locale = true,
	uppercase = false,
	no_buffers = true,
	short_units = true,
	format_human_readable = true,

-- Like it says, ot pads the decimals on % values
-- doesn't seem to work since v1.7.1
	pad_percents = 2,

-- Update interval in seconds
	update_interval = 1,

-- This is the number of times Conky will update before quitting.
-- Set to zero to run forever.
	total_run_times = 0,

-- Create own window instead of using desktop (required in nautilus)
	own_window = true,
	own_window_transparent = true,
	own_window_type = 'desktop',
	own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
 own_window_argb_visual = true,
 own_window_argb_value = 255,
	background = true,
	use_spacer = 'none',

-- Use double buffering (reduces flicker, may not work for everyone)
	double_buffer = true,

-- Minimum size of text area -adjust if you would like to user smaller fonts etc.
	minimum_width = 435, minimum_height = 195,
	--maximum_width = 300,
	--max_specials = '1024',
	max_user_text = 16384,
--default_bar_size 215 5

-- Desired output unit of all objects displaying a temperature. Parameters are
-- either "fahrenheit" or "celsius". The default unit is degree Celsius.
	temperature_unit = 'fahrenheit',

-- Draw shades?
	draw_shades = false,
	default_shade_color = '#000000',

-- Draw outlines?
	draw_outline = false,
	default_outline_color = '#000000',

--##  Color Settings
	default_color = 'b2b2b2', 
color0 = '555555',         
color1 = '483D8B',         -- Dark Slate Blue
color2 = 'B8860B',         -- Dark goldenrod
color3 = '#7FFF00',--127 255   0	Chartreuse
color4 = '8B0000',         -- Dark red
color5 = '008080',         -- Teal
color6 = '#778899',--119 136 153	LightSlateGray
color7 = 'C8C8FF',         -- (COOL)
color8 = 'FFFFCC',         -- (WARM)
color9 = 'FCCCCC',         -- (HOT) 

-- Draw borders around text
	draw_borders = false,

-- Stippled borders?
	stippled_borders = 0,

-- border margins
	border_inner_margin = 10,
	border_outer_margin = 10,

-- border width
	border_width = 1,

-- graph borders
	draw_graph_borders = false,--no
--default_graph_size 15 40
--show_graph_range = false,
--show_graph_scale = false,

-- Text alignment, other possible values are commented
alignment = 'top_left',
--alignment = 'top_right',
--alignment = 'top_middle',
--alignment = 'bottom_left',
--alignment = 'bottom_right',
--alignment = 'bottom_middle',

-- Gap between borders of screen and text
-- same thing as passing -x at command line
	gap_x = 20,
	gap_y = 25,


-- -- Lua Load -- #
--lua_load = '~/.draw-bg.lua',
-- ${lua conky_draw_bg 20 0 0 0 0 0x000000 0.2}
--lua_draw_hook_pre = 'draw_bg 20 0 0 0 0 0x000000 0.2'
--lua_draw_hook_post = 'draw_bg 20 0 0 0 0 0x000000 0.2',

-- -- Album art fix -- #
	imlib_cache_size = 0,

-- ASCII Characters
-- │ ─ ┌ ┬ ┐ └ ┴ ┘ ├ ┼ ┤
-- ║ ═ ╔ ╦ ╗ ╚ ╩ ╝ ╠ ╬ ╣

-- ↑ ↓ → ← ↔ ► ◄ ▲ ▼ « »
-- ░  ▒  ▓ ☺ ☻ ♥ ♦ ♣ ♠
-- • ◘ ○ ◙ ♂ ♀ ♪ ♫ ☼
-- ¼ ½ ¾ ® © ±

--lua_load = '~/conky-conf/testing/weather-a/scripts/lua-weather.lua',
    --lua_draw_hook_pre = 'conky_main',

lua_load = '~/conky-conf/testing/weather-a/scripts/launcher.lua',
    lua_draw_hook_post = 'main',
    lua_draw_hook_pre = 'main_box',
    lua_startup_hook = 'vars', 

};

conky.text = [[
${execi 600 ~/conky-conf/testing/weather-a/scripts/lua-weather.sh 4787519}
${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather GET}
${offset 120}${voffset -9}±${color7}${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather Feels_Like}${font}°${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather unit_temperature}
${offset 115}${voffset -3}Gust: ${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather wind_gust}
${offset 190}${voffset -65}H/L: ${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather forecast1_high} | ${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather forecast1_low}°${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather unit_temperature}${alignr}${color7}Humidity: ${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather atmosphere_humidity}
${offset 200}${voffset 90}${if_gw}${color7}${font ConkyColorsWeather:size=40}${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather condition_code}${font}
${offset 10}${voffset -10}DP: ${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather dew_point}°${alignc -40}UV Index: ${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather uv_index}${alignr}Pressure: ${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather pressure} ${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather pressure_d}
  ${color3}${execi 600 (cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<day d="1"/,1!d' | sed 's/.* t="\(.*\)" .*/\1/')}: ${color7}${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather forecast2_high} / ${color7}${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather forecast2_low}°${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather unit_temperature} \
 |  ${execi 600 grep -A 2 -Pm2 '(?<=<part p="d")[^<]+' ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed -n '7p' | grep -oPm2 '(?<=<t>)[^<]+'}  |  \
wind ${execi 600 grep -oPm4 "(?<=<s>)[^<]+" ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed -n '4p'} mph \
${execi 600 grep -A 8 -Pm2 '(?<=<part p="d")[^<]+' ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed -n '18p' | grep -oPm1 '(?<=<t>)[^<]+'} \
${alignr 20}${voffset -5}${color8}${font ConkyColorsWeather:size=20}${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather forecast2_code}${font}
  ${voffset -10}${color3}${execi 600 (cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<day d="2"/,1!d' | sed 's/.* t="\(.*\)" .*/\1/')}: ${color7}${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather forecast3_high} / ${color7}${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather forecast3_low}°${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather unit_temperature} \
 |  ${execi 600 grep -A 8 -Pm3 '(?<=<day d="2")[^<]+' ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed -n '9p' | grep -oPm3 '(?<=<t>)[^<]+'}  |  wind \
${execi 600 grep -A 10 -Pm3 '(?<=<day d="2")[^<]+' ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed -n '11p' | grep -oPm3 '(?<=<s>)[^<]+'} mph \
${execi 600 grep -A 13 -Pm3 '(?<=<day d="2")[^<]+' ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed -n '14p' | grep -oPm3 '(?<=<t>)[^<]+'} \
${alignr}${voffset -7}${color8}${font ConkyColorsWeather:size=20}${execi 600 ~/conky-conf/testing/weather-a/scripts/conkyWeather forecast3_code}${font}
#${voffset -50}
]];

autostart.sh:

#!/bin/sh
# You can use this script to create an autostart,it will cd into the theme folder before executing conky
# Conkies can be started individually through terminal from their directory (conky -c conky.conf or cd /path/to/theme/ && conky -c conky.conf)

    #killall conky

        # Making sure theme-dir is working-dir
        cd "$(dirname "$0")"

    ( set -x; setsid conky -c conkyrc --daemonize )

exit

inside scripts:
box.lua:

--[[
#########################
# conky-system-lua-V3   #
# by +WillemO @wim66    #
# v1.5 23-dec-17        #
#                       #
#########################
]]

--[[BOX WIDGET v1.1 by Wlourf 27/01/2011
This widget can drawn some boxes, even circles in your conky window
http://u-scripts.blogspot.com/2011/01/box-widget.html)

Inspired by Background by londonali1010 (2009), thanks ;-) 

The parameters (all optionals) are :
x           - x coordinate of top-left corner of the box, default = 0 = (top-left corner of conky window)
y           - y coordinate of top-left corner of the box, default = 0 = (top-left corner of conky window)
w           - width of the box, default = width of the conky window
h           - height of the box, default = height of the conky window
corners     - corners is a table for the four corners in this order : top-left, top-right,bottom-right, bottom-left
              each corner is defined in a table with a shape and a radius, available shapes are : "curve","circle","line"
              example for the same shapes for all corners:
              { {"circle",10} }
              example for first corner different from the three others
              { {"circle",10}, {"circle",5}  }              
              example for top corners differents from bottom corners
              { {"circle",10}, {"circle",10}, {"line",0}  }   
              default = { {"line",0} } i.e=no corner
operator    - set the compositing operator (needs in the conkyrc : own_window_argb_visual yes)                          
              see http://cairographics.org/operators/
              available operators are :
              "clear","source","over","in","out","atop","dest","dest_over","dest_in","dest_out","dest_atop","xor","add","saturate"
              default = "over"
border      - if border>0, the script draws only the border, like a frame, default=0
dash        - if border>0 and dash>0, the border is draw with dashes, default=0
skew_x      - skew box around x axis, default = 0
skew_y      - skew box around y axis, default = 0
scale_x     - rescale the x axis, default=1, useful for drawing elipses ...
scale_y     - rescale the x axis, default=1
angle	    - angle of rotation of the box in degrees, default = 0
              i.e. a horizontal graph
rot_x       - x point of rotation's axis, default = 0,
              relative to top-left corner of the box, (not the conky window)
rot_y       - y point of rotation's axis, default = 0              
              relative to top-left corner of the box, (not the conky window)
draw_me     - if set to false, box is not drawn (default = true or 1)
              it can be used with a conky string, if the string returns 1, the box is drawn :
              example : "${if_empty ${wireless_essid wlan0}}${else}1$endif",              
              
linear_gradient - table with the coordinates of two points to define a linear gradient,
                  points are relative to top-left corner of the box, (not the conky window)
                  {x1,y1,x2,y2}
radial_gradient - table with the coordinates of two circle to define a radial gradient,
                  points are relative to top-left corner of the box, (not the conky window)
                  {x1,y1,r1,x2,y2,r2} (r=radius)
colour      - table of colours, default = plain white {{1,0xFFFFFF,0.5}}
              this table contains one or more tables with format {P,C,A}
              P=position of gradient (0 = start of the gradient, 1= end of the gradient)
              C=hexadecimal colour 
              A=alpha (opacity) of color (0=invisible,1=opacity 100%)
              Examples :
              for a plain color {{1,0x00FF00,0.5}}
              for a gradient with two colours {{0,0x00FF00,0.5},{1,0x000033,1}}        {x=80,y=150,w=20,h=20,
        radial_gradient={20,20,0,20,20,20},
        colour={{0.5,0xFFFFFF,1},{1,0x000000,0}},
              or {{0.5,0x00FF00,1},{1,0x000033,1}} -with this one, gradient will start in the middle
              for a gradient with three colours {{0,0x00FF00,0.5},{0.5,0x000033,1},{1,0x440033,1}}
              and so on ...



To call this script in Conky, use (assuming you have saved this script to ~/scripts/):
    lua_load ~/scripts/box.lua
    lua_draw_hook_pre main_box
    
And leave one line blank or not after TEXT

Changelog:
+ v1.0 -- Original release (19.12.2010)
+ v1.1 -- Adding parameters: operator, dash, angle, skew_x, skew_y, draw_me
          corners are described in a table

--      This program is free software; you can redistribute it and/or modify
--      it under the terms of the GNU General Public License as published by
--      the Free Software Foundation version 3 (GPLv3)
--     
--      This program is distributed in the hope that it will be useful,
--      but WITHOUT ANY WARRANTY; without even the implied warranty of
--      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--      GNU General Public License for more details.
--     
--      You should have received a copy of the GNU General Public License
--      along with this program; if not, write to the Free Software
--      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
--      MA 02110-1301, USA.		


]]

  
require 'cairo'
    
function conky_main_box()

    if conky_window==nil then return end
    
	---------------------- PARAMETERS BEGIN HERE
                                                          
    local boxes_settings={

        {
	x=12,y=8,w=455,h=221,
	colour= { {1,0x000000,0.5} }, 
        corners={ {"circle",5},},
	},

	{
	x=7,y=3,w=465,h=230,
	colour=color_x, linear_gradient={128,50,128,600}, 
        corners={ {"circle",5},}, border=4 
	},

--[[	{
	x=6,y=10,w=291,h=475,
	colour= { {0,0xFFFFFF,0.025}, {0.5,0xC2C2C2,0.25}, {1,0xFFFFFF,0.025}}, linear_gradient={0,0,0,642},
	},--]]

}

    ---------------------------- PARAMETERS END HERE
    
    local cs=cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
    local cr=cairo_create(cs)
    
    if tonumber(conky_parse("$updates"))<5 then return end
    for i in pairs(boxes_settings) do
        draw_box (cr,boxes_settings[i])
    end
    cairo_destroy(cr)
    cairo_surface_destroy(cs)    
end

    
function draw_box(cr,t)

	if t.draw_me == true then t.draw_me = nil end
	if t.draw_me ~= nil and conky_parse(tostring(t.draw_me)) ~= "1" then return end	

    local table_corners={"circle","curve","line"}

    local t_operators={
        clear   = CAIRO_OPERATOR_CLEAR,
        source  = CAIRO_OPERATOR_SOURCE,
        over    = CAIRO_OPERATOR_OVER,
        ["in"]      = CAIRO_OPERATOR_IN,
        out     = CAIRO_OPERATOR_OUT,
        atop    = CAIRO_OPERATOR_ATOP,
        dest    = CAIRO_OPERATOR_DEST,
        dest_over   = CAIRO_OPERATOR_DEST_OVER,
        dest_in = CAIRO_OPERATOR_DEST_IN,
        dest_out = CAIRO_OPERATOR_DEST_OUT,
        dest_atop = CAIRO_OPERATOR_DEST_ATOP,
        xor = CAIRO_OPERATOR_XOR,
        add = CAIRO_OPERATOR_ADD,
        saturate =  CAIRO_OPERATOR_SATURATE,
    }
        
    function rgba_to_r_g_b_a(tc)
        --tc={position,colour,alpha}
        local colour = tc[2]
        local alpha = tc[3]
        return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
    end

    function table.copy(t)
      local t2 = {}
      for k,v in pairs(t) do
       t2[k] = {v[1],v[2]}
      end
      return t2
    end

    function draw_corner(num,t)
        local shape=t[1]
        local radius=t[2]
        local x,y = t[3],t[4]
        if shape=="line" then
            if num == 1 then cairo_line_to(cr,radius,0) 
                elseif num == 2 then cairo_line_to(cr,x,radius) 
                elseif num == 3 then cairo_line_to(cr,x-radius,y)
                elseif num == 4 then cairo_line_to(cr,0,y-radius)
            end
        end
        if shape=="circle" then
		    local PI = math.pi
           if num == 1 then cairo_arc(cr,radius,radius,radius,-PI,-PI/2)
                elseif num == 2 then cairo_arc(cr,x-radius,y+radius,radius,-PI/2,0)
                elseif num == 3 then cairo_arc(cr,x-radius,y-radius,radius,0,PI/2) 
                elseif num == 4 then cairo_arc(cr,radius,y-radius,radius,PI/2,-PI)
            end
        end
        if shape=="curve" then
            if num == 1 then cairo_curve_to(cr,0,radius ,0,0 ,radius,0) 
                elseif num == 2 then cairo_curve_to(cr,x-radius,0, x,y, x,radius)
                elseif num == 3 then cairo_curve_to(cr,x,y-radius, x,y, x-radius,y)
                elseif num == 4 then cairo_curve_to(cr,radius,y, x,y, 0,y-radius)
            end
        end        
    end   

    --check values and set default values
    if border_COLOR == "default" then color_x = { {1,0x34495E,1} } end
    if border_COLOR == "green" then color_x = { {0,0x003E00,1}, {0.5,0x03F404,1}, {1,0x003E00,1} } end
    if border_COLOR == "blue" then color_x =  { {0,0x0032FF,1}, {0.5,0x00CCFF,1}, {1,0x0032FF,1} } end
    if border_COLOR == "orange" then color_x =  { {0,0xE05700,1}, {0.5,0xFFD145,1}, {1,0xE05700,1} } end
    if border_COLOR == "black" then color_x =  { {0.15,0x101010,1}, {0.5,0xA1A1A1,1}, {0.85,0x101010,1} } end
                                                                                       
    if t.x == nil then t.x = 0 end
    if t.y == nil then t.y = 0 end
    if t.w == nil then t.w = conky_window.width end
    if t.h == nil then t.h = conky_window.height end
    if t.radius == nil then t.radius = 0 end
    if t.border == nil then t.border = 0 end
    if t.colour==nil then t.colour={{1,0x34495E,1}} end
    if t.linear_gradient ~= nil then 
        if #t.linear_gradient ~= 4 then
            t.linear_gradient = {t.x,t.y,t.width,t.height}
        end
    end 
    if t.angle==nil then t.angle = 0 end

	if t.skew_x == nil then t.skew_x=0  end
	if t.skew_y == nil then  t.skew_y=0 end
	if t.scale_x==nil then t.scale_x=1 end
	if t.scale_y==nil then t.scale_y=1 end	
	if t.rot_x == nil then t.rot_x=0  end
	if t.rot_y == nil then  t.rot_y=0 end
    
    if t.operator == nil then t.operator = "over" end
    if (t_operators[t.operator]) == nil then
        print ("wrong operator :",t.operator)
        t.operator = "over"
    end
    
    if t.radial_gradient ~= nil then 
        if #t.radial_gradient ~= 6 then
            t.radial_gradient = {t.x,t.y,0, t.x,t.y, t.width}
        end
    end 
    
    for i=1, #t.colour do    
        if #t.colour[i]~=3 then 
            print ("error in color table")
            t.colour[i]={1,0xFFFFFF,1} 
        end
    end

    if t.corners == nil then t.corners={ {"line",0} } end
    local t_corners = {}
    local t_corners = table.copy(t.corners)
    --don't use t_corners=t.corners otherwise t.corners is altered

    --complete the t_corners table if needed
    for i=#t_corners+1,4 do    
        t_corners[i]=t_corners[#t_corners]
        local flag=false
        for j,v in pairs(table_corners) do flag=flag or (t_corners[i][1]==v) end 
        if not flag then print ("error in corners table :",t_corners[i][1]);t_corners[i][1]="curve"  end
    end

    --this way :    
    --    t_corners[1][4]=x    
    --    t_corners[2][3]=y
    --doesn't work
    t_corners[1]={t_corners[1][1],t_corners[1][2],0,0}
    t_corners[2]={t_corners[2][1],t_corners[2][2],t.w,0}
    t_corners[3]={t_corners[3][1],t_corners[3][2],t.w,t.h}    
    t_corners[4]={t_corners[4][1],t_corners[4][2],0,t.h}        

    t.no_gradient = (t.linear_gradient == nil ) and (t.radial_gradient == nil )

    cairo_save(cr)
    cairo_translate(cr, t.x, t.y)
    if t.rot_x~=0 or t.rot_y~=0 or t.angle~=0 then
        cairo_translate(cr,t.rot_x,t.rot_y)
        cairo_rotate(cr,t.angle*math.pi/180)
        cairo_translate(cr,-t.rot_x,-t.rot_y)
    end
    if t.scale_x~=1 or t.scale_y~=1 or t.skew_x~=0 or t.skew_y~=0 then
	    local matrix0 = cairo_matrix_t:create()
	    tolua.takeownership(matrix0)
	    cairo_matrix_init (matrix0, t.scale_x,math.pi*t.skew_y/180	, math.pi*t.skew_x/180	,t.scale_y,0,0)
	    cairo_transform(cr,matrix0)    
    end
    
    local tc=t_corners
    cairo_move_to(cr,tc[1][2],0)
    cairo_line_to(cr,t.w-tc[2][2],0)
    draw_corner(2,tc[2])
    cairo_line_to(cr,t.w,t.h-tc[3][2])
    draw_corner(3,tc[3])
    cairo_line_to(cr,tc[4][2],t.h)
    draw_corner(4,tc[4])
    cairo_line_to(cr,0,tc[1][2])
    draw_corner(1,tc[1])
    
    if t.no_gradient then
        cairo_set_source_rgba(cr,rgba_to_r_g_b_a(t.colour[1]))
    else
        if t.linear_gradient ~= nil then
            pat = cairo_pattern_create_linear (t.linear_gradient[1],t.linear_gradient[2],t.linear_gradient[3],t.linear_gradient[4])
        elseif t.radial_gradient ~= nil then
            pat = cairo_pattern_create_radial (t.radial_gradient[1],t.radial_gradient[2],t.radial_gradient[3],
            	t.radial_gradient[4],t.radial_gradient[5],t.radial_gradient[6])
        end
        for i=1, #t.colour do
            cairo_pattern_add_color_stop_rgba (pat, t.colour[i][1], rgba_to_r_g_b_a(t.colour[i]))
        end
        cairo_set_source (cr, pat)
        cairo_pattern_destroy(pat)
    end 
     
    cairo_set_operator(cr,t_operators[t.operator]) 

    if t.border>0 then
        cairo_close_path(cr)
        if t.dash ~= nil then cairo_set_dash(cr, t.dash, 1, 0.0) end
        cairo_set_line_width(cr,t.border)
        cairo_stroke(cr)
    else
        cairo_fill(cr)
    end

    cairo_restore(cr)
end

conkyWeather:

#!/bin/bash
# adapted from conkycolors by quakeguy
# --- http://weather.yahoo.com/ ---
# http://weather.yahooapis.com/forecastrss?w=WOEID&u=UNIT
# WOEID: Halle - 656853
# UNIT: c - Celsius, f - Fahrenheit
# (old id: Halle - GMXX0048)

# changed to weather.com
# since  03/2016 yahoo requires oauth2

#--- Cities: BEGIN
#GMXX0048 - Halle (Saale)
#GMXX0072 - Leipzig
#GMXX0007 - Berlin
#UKXX0085 - London
#ITXX0067 - Rom
#SPXX0050 - Madrid
#RSXX0063 - Moskau
#SFXX0010 - Kapstadt
#USNY0996 - New York
#USCA0638 - Los Angeles
#BRXX0201 - Rio de Janeiro
#CAXX0301 - Montreal
#EGXX0004 - Kairo
#CHXX0008 - Peking
#KSXX0037 - Seoul
#JAXX0085 - Tokio
#VMXX0006 - Hanoi
#ASXX0112 - Sydney
#--- Cities: END

# set location
LOCATION="USVA0733"

# unit: m - metric, * - non metric
UNIT="*"

# weekdays in short form (german)
function getWeekDay() {
	case "$1" in
		Monday) echo "Mo." ;;
		Tuesday) echo "Tu." ;;
		Wednesday) echo "We." ;;
		Thursday) echo "Th." ;;
		Friday) echo "Fr." ;;
		Saturday) echo "Sa." ;;
		Sunday) echo "Su." ;;
	esac
}

#MAP_OLD=(1 2 3 n m x x y s h t h i p p 8 q u w 7 0 9 4 6 6 - f D d C c A a B b v 5 k k g j o r r - G 0 K)
MAP_CODE=(1 2 3 n m x x y s h t i i p p 8 q u w 7 0 9 4 6 8 - f e e C c A a B b v 5 k k k j o r r - G 0 K)
#change__(- - -                 c     x   x           - - c   / c c x x x x / x   -     c                )
#________(0                   1                   2                   3                   4              )

if   [ "$1" = "GET" ]; then
  curl -s 'http://wxdata.weather.com/wxdata/weather/local/'$LOCATION'?cc=*&dayf=5&unit='$UNIT -o ~/conky-conf/testing/weather-a/scripts/cache/weather.xml
elif [ "$1" = "unit_temperature" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<ut>/,1!d' | sed 's/.*<ut>\(.*\)<\/ut>.*/\1/'
elif [ "$1" = "unit_speed" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<us>/,1!d' | sed 's/.*<us>\(.*\)<\/us>.*/\1/'
elif [ "$1" = "location_city" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<dnam>/,1!d' | sed 's/.*<dnam>\(.*\)<\/dnam>.*/\1/' | sed 's/\(.*\),\(.*\),\(.*\)/\1/'
elif [ "$1" = "location_time" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<tm>/,1!d' | sed 's/.*<tm>\(.*\)<\/tm>.*/\1/'
elif [ "$1" = "condition_day" ]; then
	grep -oPm1 "(?<=<t>)[^<]+" ~/conky-conf/testing/weather-a/scripts/cache/weather.xml
elif [ "$1" = "Feels_Like" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<flik>/,1!d' | sed 's/.*<flik>\(.*\)<\/flik>.*/\1/'
elif [ "$1" = "wind_gust" ]; then
	grep -oPm1 "(?<=<gust>)[^<]+" ~/conky-conf/testing/weather-a/scripts/cache/weather.xml
elif [ "$1" = "wind_d" ]; then
	grep -oPm2 "(?<=<t>)[^<]+" ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed -n '2p'
elif [ "$1" = "wind_chill" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<flik>/,1!d' | sed 's/.*<flik>\(.*\)<\/flik>.*/\1/'
elif [ "$1" = "wind_direction" ]; then
	WIND_DIRECTION=$(cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<d>/,1!d' | sed -n '2p' | sed 's/.*<d>\(.*\)<\/d>.*/\1/')
	if [ "$WIND_DIRECTION" -lt "12" ]; then
		DR="N"
	elif [ "$WIND_DIRECTION" -lt "34" ]; then
		DR="NNE"
	elif [ "$WIND_DIRECTION" -lt "57" ]; then
		DR="NE"
	elif [ "$WIND_DIRECTION" -lt "79" ]; then
		DR="NEE"
	elif [ "$WIND_DIRECTION" -lt "102" ]; then
		DR="E"
	elif [ "$WIND_DIRECTION" -lt "124" ]; then
		DR="SEE"
	elif [ "$WIND_DIRECTION" -lt "147" ]; then
		DR="SE"
	elif [ "$WIND_DIRECTION" -lt "169" ]; then
		DR="SSE"
	elif [ "$WIND_DIRECTION" -lt "192" ]; then
		DR="S"
	elif [ "$WIND_DIRECTION" -lt "214" ]; then
		DR="SSW"
	elif [ "$WIND_DIRECTION" -lt "237" ]; then
		DR="SW"
	elif [ "$WIND_DIRECTION" -lt "259" ]; then
		DR="SWW"
	elif [ "$WIND_DIRECTION" -lt "282" ]; then
		DR="W"
	elif [ "$WIND_DIRECTION" -lt "304" ]; then
		DR="NWW"
	elif [ "$WIND_DIRECTION" -lt "327" ]; then
		DR="NW"
	elif [ "$WIND_DIRECTION" -lt "349" ]; then
		DR="NNW"
	else
		DR="N"
	fi
	WIND_SPEED=$(cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<s>/,1!d' | sed -n '1p' | sed 's/.*<s>\(.*\)<\/s>.*/\1/')
	WS=${WIND_SPEED/.*}
# unit kmh or mph
  UNIT=$(cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<us>/,1!d' | sed 's/.*<us>\(.*\)<\/us>.*/\1/')
# calcualte wind speed in kmh as integer
  if [ "$UNIT" == "mph" ]; then
    WS=$(echo $WS'*1.60934' | bc | sed 's/[.].*//')
  fi
### speed 'calm' = 0
  if [ "$WS" == "calm" ]; then
    WS=0
  fi
# 0: calm (0 kmh), light air (1-5 kmh)
	if [ "$WS" -lt "6" ]; then
		echo "%"
# 1: light breeze (6-11 kmh), gentle breeze (12-19 kmh)
	elif [ "$WS" -lt "20" ]; then
		case "$DR" in
			N)   echo "9" ;;
			NNE) echo ":" ;;
			NE)  echo ";" ;;
			NEE) echo "<" ;;
			E)   echo "=" ;;
			SEE) echo ">" ;;
			SE)  echo "?" ;;
			SSE) echo "@" ;;
			S)   echo "1" ;;
			SSW) echo "2" ;;
			SW)  echo "3" ;;
			SWW) echo "4" ;;
			W)   echo "5" ;;
			NWW) echo "6" ;;
			NW)  echo "7" ;;
			NNW) echo "8" ;;
		esac
# 2: moderate breeze (20-28 kmh), fresh breeze (29-38 kmh)
	elif [ "$WS" -lt "39" ]; then
		case "$DR" in
			N)   echo "I" ;;
			NNE) echo "J" ;;
			NE)  echo "K" ;;
			NEE) echo "L" ;;
			E)   echo "M" ;;
			SEE) echo "N" ;;
			SE)  echo "O" ;;
			SSE) echo "P" ;;
			S)   echo "A" ;;
			SSW) echo "B" ;;
			SW)  echo "C" ;;
			SWW) echo "D" ;;
			W)   echo "E" ;;
			NWW) echo "F" ;;
			NW)  echo "G" ;;
			NNW) echo "H" ;;
		esac
# 3: strong breeze (39-49 kmh), moderate gale (50-61 kmh)
	elif [ "$WS" -lt "62" ]; then
		case "$DR" in
			N)   echo "Y" ;;
			NNE) echo "Z" ;;
			NE)  echo "[" ;;
			NEE) echo "\\" ;;
			E)   echo "]" ;;
			SEE) echo "^" ;;
			SE)  echo "_" ;;
			SSE) echo "\`" ;;
			S)   echo "Q" ;;
			SSW) echo "R" ;;
			SW)  echo "S" ;;
			SWW) echo "T" ;;
			W)   echo "U" ;;
			NWW) echo "V" ;;
			NW)  echo "W" ;;
			NNW) echo "X" ;;
		esac
# 4: fresh gale (62-74 kmh), strong gale (75-88 kmh), whole gale (89-102 kmh), storm (103-117 kmh), hurricane (>117 kmh)
	else
		case "$DR" in
			N)   echo "i" ;;
			NNE) echo "j" ;;
			NE)  echo "k" ;;
			NEE) echo "l" ;;
			E)   echo "m" ;;
			SEE) echo "n" ;;
			SE)  echo "o" ;;
			SSE) echo "p" ;;
			S)   echo "a" ;;
			SSW) echo "b" ;;
			SW)  echo "c" ;;
			SWW) echo "d" ;;
			W)   echo "e" ;;
			NWW) echo "f" ;;
			NW)  echo "g" ;;
			NNW) echo "h" ;;
		esac
	fi
elif [ "$1" = "wind_speed" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<s>/,1!d' | sed -n '1p' | sed 's/.*<s>\(.*\)<\/s>.*/\1/'
elif [ "$1" = "atmosphere_humidity" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<hmid>/,1!d' | sed -n '1p' | sed 's/.*<hmid>\(.*\)<\/hmid>.*/\1/'
elif [ "$1" = "dew_point" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<dewp>/,1!d' | sed -n '1p' | sed 's/.*<dewp>\(.*\)<\/dewp>.*/\1/'
elif [ "$1" = "uv_index" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<i>/,1!d' | sed -n '1p' | sed 's/.*<i>\(.*\)<\/i>.*/\1/'
elif [ "$1" = "atmosphere_visibility" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<vis>/,1!d' | sed 's/.*<vis>\(.*\)<\/vis>.*/\1/'
elif [ "$1" = "astronomy_sunrise" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<sunr>/,1!d' | sed -n '1p' | sed 's/.*<sunr>\(.*\)<\/sunr>.*/\1/'
elif [ "$1" = "astronomy_sunset" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<suns>/,1!d' | sed -n '1p' | sed 's/.*<suns>\(.*\)<\/suns>.*/\1/'
elif [ "$1" = "condition_temp" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<tmp>/,1!d' | sed 's/.*<tmp>\(.*\)<\/tmp>.*/\1/'
elif [ "$1" = "wind_d" ]; then
	grep -oPm2 "(?<=<t>)[^<]+" ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed -n '2p'
elif [ "$1" = "condition_temp" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<flik>/,1!d' | sed 's/.*<flik>\(.*\)<\/tmp>.*/\1/'
elif [ "$1" = "pressure" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<r>/,1!d' | sed 's/.*<r>\(.*\)<\/r>.*/\1/'
elif [ "$1" = "pressure_d" ]; then
	grep -oPm1 "(?<=<d>)[^<]+" ~/conky-conf/testing/weather-a/scripts/cache/weather.xml
elif [ "$1" = "condition_day" ]; then
	grep -oPm1 "(?<=<t>)[^<]+" ~/conky-conf/testing/weather-a/scripts/cache/weather.xml 
elif [ "$1" = "condition_code" ]; then
	CONDITION_CODE=$(cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<icon>/,1!d' | sed -n '1p' | sed 's/.*<icon>\(.*\)<\/icon>.*/\1/')
  echo ${MAP_CODE[$CONDITION_CODE]}
elif [ "$1" = "condition_date" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<lsup>/,1!d' | sed -n '1p' | sed 's/.*<lsup>\(.*\)<\/lsup>.*/\1/'
elif [ "$1" = "forecast1_day" ]; then
	DAY1=$(cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<day d="0"/,1!d' | sed 's/.* t="\(.*\)" .*/\1/')
	getWeekDay $DAY1
elif [ "$1" = "forecast1_low" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<low>/,1!d' | sed -n '1p' | sed 's/.*<low>\(.*\)<\/low>.*/\1/'
elif [ "$1" = "forecast1_high" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<hi>/,1!d' | sed -n '1p' | sed 's/.*<hi>\(.*\)<\/hi>.*/\1/'
elif [ "$1" = "forecast1_code" ]; then
	FORECAST1_CODE=$(cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<icon>/,1!d' | sed -n '4p' | sed 's/.*<icon>\(.*\)<\/icon>.*/\1/')
  echo ${MAP_CODE[$FORECAST1_CODE]}
elif [ "$1" = "forecast1_rain" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<ppcp>/,1!d' | sed -n '2p' | sed 's/.*<ppcp>\(.*\)<\/ppcp>.*/\1/'
elif [ "$1" = "forecast2_day" ]; then
	DAY2=$(cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<day d="1"/,1!d' | sed 's/.* t="\(.*\)" .*/\1/')
	getWeekDay $DAY2
elif [ "$1" = "forecast2_low" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<low>/,1!d' | sed -n '2p' | sed 's/.*<low>\(.*\)<\/low>.*/\1/'
elif [ "$1" = "forecast2_high" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<hi>/,1!d' | sed -n '2p' | sed 's/.*<hi>\(.*\)<\/hi>.*/\1/'
elif [ "$1" = "forecast2_code" ]; then
	FORECAST2_CODE=$(cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<icon>/,1!d' | sed -n '5p' | sed 's/.*<icon>\(.*\)<\/icon>.*/\1/')
  echo ${MAP_CODE[$FORECAST2_CODE]}
elif [ "$1" = "forecast2_rain" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<ppcp>/,1!d' | sed -n '3p' | sed 's/.*<ppcp>\(.*\)<\/ppcp>.*/\1/'
elif [ "$1" = "forecast3_day" ]; then
	DAY3=$(cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<day d="2"/,1!d' | sed 's/.* t="\(.*\)" .*/\1/')
	getWeekDay $DAY3
elif [ "$1" = "forecast3_low" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<low>/,1!d' | sed -n '3p' | sed 's/.*<low>\(.*\)<\/low>.*/\1/'
elif [ "$1" = "forecast3_high" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<hi>/,1!d' | sed -n '3p' | sed 's/.*<hi>\(.*\)<\/hi>.*/\1/'
elif [ "$1" = "forecast3_code" ]; then
	FORECAST3_CODE=$(cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<icon>/,1!d' | sed -n '7p' | sed 's/.*<icon>\(.*\)<\/icon>.*/\1/')
  echo ${MAP_CODE[$FORECAST3_CODE]}
elif [ "$1" = "forecast3_rain" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<ppcp>/,1!d' | sed -n '5p' | sed 's/.*<ppcp>\(.*\)<\/ppcp>.*/\1/'
elif [ "$1" = "forecast4_day" ]; then
	DAY4=$(cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<day d="3"/,1!d' | sed 's/.* t="\(.*\)" .*/\1/')
	getWeekDay $DAY4
elif [ "$1" = "forecast4_low" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<low>/,1!d' | sed -n '4p' | sed 's/.*<low>\(.*\)<\/low>.*/\1/'
elif [ "$1" = "forecast4_high" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<hi>/,1!d' | sed -n '4p' | sed 's/.*<hi>\(.*\)<\/hi>.*/\1/'
elif [ "$1" = "forecast4_code" ]; then
	FORECAST4_CODE=$(cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<icon>/,1!d' | sed -n '9p' | sed 's/.*<icon>\(.*\)<\/icon>.*/\1/')
  echo ${MAP_CODE[$FORECAST4_CODE]}
elif [ "$1" = "forecast4_rain" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<ppcp>/,1!d' | sed -n '7p' | sed 's/.*<ppcp>\(.*\)<\/ppcp>.*/\1/'
elif [ "$1" = "forecast5_day" ]; then
	DAY5=$(cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<day d="4"/,1!d' | sed 's/.* t="\(.*\)" .*/\1/')
	getWeekDay $DAY5
elif [ "$1" = "forecast5_low" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<low>/,1!d' | sed -n '5p' | sed 's/.*<low>\(.*\)<\/low>.*/\1/'
elif [ "$1" = "forecast5_high" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<hi>/,1!d' | sed -n '5p' | sed 's/.*<hi>\(.*\)<\/hi>.*/\1/'
elif [ "$1" = "forecast5_code" ]; then
	FORECAST5_CODE=$(cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<icon>/,1!d' | sed -n '11p' | sed 's/.*<icon>\(.*\)<\/icon>.*/\1/')
  echo ${MAP_CODE[$FORECAST5_CODE]}
elif [ "$1" = "forecast5_rain" ]; then
	cat ~/conky-conf/testing/weather-a/scripts/cache/weather.xml | sed '/<ppcp>/,1!d' | sed -n '9p' | sed 's/.*<ppcp>\(.*\)<\/ppcp>.*/\1/'
else
	echo "Error: undefined option"
fi

launcher.lua:

--paths-must-be->/home/worldchampions/.conky/...
--not--> ~/
function conky_main()
dofile ('/home/manuel/conky-conf/testing/weather-a/scripts/box.lua')
dofile ('/home/manuel/conky-conf/testing/weather-a/scripts/lua-weather.lua')
dofile ('/home/manuel/conky-conf/testing/weather-a/scripts/settings.lua')


        
        

    
    --call of the two mains functions in the lua files
    conky_main_box()
       

end
                                                                                                                                                                                
                   

lua-weather.lua:

--[[ 
lua-weather.lua, written by <damo>, July 2016

---------------------------------------------
Use this in a conky with

    lua_load /path/to/lua-weather.lua
    lua_draw_hook_pre conky_main

In the conky, get the weather data from lua-weather.sh with

TEXT
${execi <interval> /path/to/lua-weather.sh}

---------------------------------------------]]

require 'cairo'

-- set default font
--fontface="Dustismo"
fontface="CaviarDreams"

function conky_main()
    if conky_window==nil then return end
    cs=cairo_xlib_surface_create(conky_window.display,
                                        conky_window.drawable,
                                        conky_window.visual,
                                        conky_window.width,
                                        conky_window.height)
    cr=cairo_create(cs)
    
    xW=160      -- x pos wind dial centre
    yW=90       -- y pos wind dial centre
    radiusW=60  -- radiusW wind dial
    xT=30       -- x pos temp bar (top)
    yT=11       -- y pos temp bar (top)
    wT=6        -- width temp bar
    hT=150      -- height temp bar
    xSun=340    -- x pos sun dial centre
    ySun=90     -- y pos sun dial centre
    radiusSun=60-- radius sun dial
    datafile="/home/manuel/weather.txt"  -- textfile to hold lua-weather.sh output
    
    direction,windS,temperature,sunrise,sunset,loc,wx = get_vals() 

    local updates=conky_parse('${updates}')
    update_num=tonumber(updates)

    if update_num>5 then
        draw_widgets()
    end

    cairo_destroy(cr)
    cairo_surface_destroy(cs)
    cr=nil
end

--  Choose the widgets to be displayed:
function draw_widgets()
    draw_thermometer(cr,xT,yT,wT,hT)
    draw_wind_rose()
    draw_sun_ring()
end

-- read values from datafile
function get_vals()
    local path = datafile
    local file = io.open( path)
    local array = {}
    local i=0
    
    if (file) then
        -- read all contents of file into array
        for line in file:lines() do
            i=i+1
            array[i]=line
        end
        file:close()

        dir=tostring(array[1]) -- get wind direction, convert to value required
        winddir=-math.pi*(tonumber(dir))/180
        wind_speed=tostring(array[2])  -- windspeed knots
        temperature=tonumber(array[5])
        sunrise=array[3]
        sunset=array[4]
        location=array[6]
        weather=array[7]

        return winddir,wind_speed,temperature,sunrise,sunset,location,weather
    else
        print("datafile " .. datafile .. " not found")
    end
end

-- convert degree to rad 
function angle_to_position(start_angle, current_angle)
    local pos = start_angle + current_angle
    return pos * math.pi/180
end

function draw_sun_ring()
   
    local hours=os.date("%I")
    local mins=os.date("%M")
    current_time=(hours .. mins)

    mins_arc = 360/60*mins
    hours_arc = (360/24*hours + mins_arc/24) + 90
    
    start_angle = 90    -- south
    end_angle = 360
    start_arc = 0
    stop_arc = 0

    -- get times and angle position from function sun_rise_set()
    sunrise,sunset,sun_rise,sun_set = sun_rise_set()

    local border_pat=cairo_pattern_create_linear(xSun,ySun-radiusSun*1.25,xSun,ySun+radiusSun*1.25)
    
    cairo_pattern_add_color_stop_rgba(border_pat,0,1,1,0,0.3)
    cairo_pattern_add_color_stop_rgba(border_pat,0.4,0.9,0.9,0.2,0.2)
    cairo_pattern_add_color_stop_rgba(border_pat,0.55,0.9,0.2,0,0.2)
    cairo_pattern_add_color_stop_rgba(border_pat,0.7,0,0.1,1,0.3)
    cairo_set_source(cr,border_pat)
    -- draw ring, starting at south position ( = midnight/00hrs)
    cairo_arc(cr, xSun, ySun, radiusSun, angle_to_position(start_angle, 0), angle_to_position(start_angle, end_angle))
    --  set width of ring
    cairo_set_line_width(cr,radiusSun*0.06)
    cairo_stroke(cr)
    cairo_pattern_destroy (pat)

    -- draw sun
    -- get position on circumference ( = time from midnight (south), 24hr clock)
    sun_pos=angle_to_position(start_angle,hours_arc)
    local sunx=xSun - (math.sin(-sun_pos)*radiusSun)
    local suny=ySun - (math.cos(-sun_pos)*radiusSun)
    -- set colour & alpha, for day/night
    if ( tonumber(current_time) > tonumber(sunrise) ) and ( tonumber(current_time) < tonumber(sunset) ) then
        r,g,b,a = 1,1,0,0.8 --day
    else
        r,g,b,a = 0, 255, 0, 0.8 --night
    end
    cairo_set_source_rgba (cr,r,g,b,a)
    cairo_arc(cr,sunx,suny,radiusSun*0.09,0,360)
    cairo_fill(cr)
    
    local r,g,b,a = 1,1,0,0.8
    cairo_set_source_rgba (cr,r,g,b,a)
    cairo_set_line_width(cr,2)
    cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND)

    -- draw sunrise mark
    local sunrise_x=xSun - (math.sin(-sun_rise)*radiusSun*1.05)
    local sunrise_y=ySun - (math.cos(-sun_rise)*radiusSun*1.05)
    local sunrise_xc=xSun - (math.sin(-sun_rise)*radiusSun*0.95)
    local sunrise_yc=ySun - (math.cos(-sun_rise)*radiusSun*0.95)
    cairo_move_to(cr,sunrise_x,sunrise_y)
    cairo_line_to(cr,sunrise_xc,sunrise_yc)
    cairo_stroke(cr)
    -- draw sunset mark
    local sunset_x=xSun - (math.sin(-sun_set)*radiusSun*1.05)
    local sunset_y=ySun - (math.cos(-sun_set)*radiusSun*1.05)
    local sunset_xc=xSun - (math.sin(-sun_set)*radiusSun*0.95)
    local sunset_yc=ySun - (math.cos(-sun_set)*radiusSun*0.95)
    local r,g,b,a = 0, 255, 0, 0.8
    cairo_set_source_rgba (cr,r,g,b,a)
    cairo_move_to(cr,sunset_x,sunset_y)
    cairo_line_to(cr,sunset_xc,sunset_yc)
    cairo_stroke(cr)
    --  print sunrise/sunset text
    sun_text(sunrise_x,sunrise_y,sunset_x,sunset_y)
end

function sun_text(xr,yr,xs,ys)
    -- display sunrise time
    local r,g,b,a = 1,1,0,0.8
    cairo_set_source_rgba (cr,r,g,b,a)
    print_text(cr,sunrise,xr-4,yr,4,13)
    print_text(cr,"sunrise",xr-4,yr+8,4,11)
    
    -- display sunset time
    local r,g,b,a = 0, 255, 0, 0.8
    cairo_set_source_rgba (cr,r,g,b,a)
    print_text(cr,sunset,xs,ys+10,0,13)
    print_text(cr,"sunset",xs,ys+18,0,11)
    
    -- display time
    local current_time = os.date("%I:%M")
    local fontface="CaviarDreams"
    local r,g,b,a = 1,1,1,0.6
    cairo_set_source_rgba (cr,r,g,b,a)
    cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
    cairo_set_font_size (cr,24)
    local xt,yt = position_text(cr,current_time,xSun,ySun-12,2)
    cairo_move_to (cr,xt,yt)
    cairo_show_text (cr,current_time)
    cairo_stroke (cr)
    
    -- display date
    local cal = os.date("%a %d %b")
    local fontface="CaviarDreams"
    local r,g,b,a = 1,1,1,0.8
    cairo_set_source_rgba (cr,r,g,b,a)
    cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
    cairo_set_font_size (cr,15)
    local xt,yt = position_text(cr,cal,xSun,ySun+2,1)
    cairo_move_to (cr,xt,yt)
    cairo_show_text (cr,cal)
    cairo_stroke (cr)
    
    --  print location
    local fontface="CaviarDreams"
    local r,g,b,a = 1,1,1,0.8
    cairo_set_source_rgba (cr,r,g,b,a)
    cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
    cairo_set_font_size (cr,13)
    local xt,yt = position_text(cr,loc,xSun,ySun+20,1)
    cairo_move_to (cr,xt,yt)
    cairo_show_text (cr,loc)
    cairo_stroke (cr)
end

function sun_rise_set()
    sunupH = string.sub(sunrise,1,2)
    sunupM = string.sub(sunrise,3,4)
    sundownH = string.sub(sunset,1,2)
    sundownM = string.sub(sunset,3,4)

    minSR_arc = 360/60*sunupM
    hourSR_arc = (360/24*sunupH + minSR_arc/24) + 90
    pos_SR = angle_to_position(start_angle,hourSR_arc)

    minSS_arc = 360/60*sundownM
    hourSS_arc = (360/24*sundownH + minSS_arc/24) + 90
    pos_SS = angle_to_position(start_angle,hourSS_arc)

    return sunrise,sunset,pos_SR,pos_SS
end

function draw_thermometer(cr,x,y,wT,hT)
    local alpha=0.8
    HT = y+hT
    pat = cairo_pattern_create_linear (x,y,wT,HT)
    cairo_pattern_add_color_stop_rgba (pat, 1,   0,  0, 1, alpha)
    cairo_pattern_add_color_stop_rgba (pat, 0.4, 1,0.8, 0, alpha)
    cairo_pattern_add_color_stop_rgba (pat, 0.3, 1,0.3, 0, alpha)
    cairo_pattern_add_color_stop_rgba (pat, 0, 1,0, 0, alpha)

    cairo_rectangle (cr, x,y,wT,HT)
    cairo_set_source (cr, pat)
    cairo_fill (cr)
    cairo_pattern_destroy (pat)

    draw_temperature(cr,x,y,hT,temperature)
end

function draw_temperature(cr,x,y,hT,Tdegrees)
    local range=hT/100
    local zero = y + range*60
    local T = Tdegrees*range
    t = tostring(Tdegrees)
    t = ( t .. "°F" )
    cairo_set_source_rgba (cr,1,1,1,0.5)
    cairo_set_line_width(cr,1)

    for i = 0,100,10 do -- draw 10 degree marks
        local l = 3
        local xT = x-1
        if ( i == 60 ) then -- longer mark for freezing point
            xT = x-6
            l = -12
        end
        cairo_move_to (cr,xT,y)
        cairo_rel_line_to (cr,-l,0)
        cairo_stroke (cr)
        y = y + range*10
    end

    cairo_set_source_rgba (cr,0, 255, 0, 0.8)
    cairo_set_line_width(cr,3)
    cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND)
    cairo_move_to(cr,x-1,zero-T)    -- temperature indicator
    cairo_rel_line_to(cr,7,0)

    -- temperature text
    print_text(cr,t,x+28,zero-T,1,11)
    -- zero degrees text
    print_text(cr,"0",x-12,zero,1,12)
end

function draw_wind_rose()
    draw_marks(cr,xW,yW,radiusW)
    draw_WindArrow(cr,xW,yW,50,direction,radiusW-8)
    draw_NESW(cr,xW,yW,radiusW,10)
    
    --  print windspeed
    local fontface="CaviarDreams"
    local r,g,b,a = 1,1,1,0.8
    cairo_set_source_rgba (cr,r,g,b,a)
    cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
    cairo_set_font_size (cr,16)
    local xt,yt = position_text(cr,windS,xW,yW,2)
    cairo_move_to (cr,xt,yt)
    cairo_show_text (cr,windS)
    cairo_stroke (cr)

    --  print weather conditions
    local fontface="CaviarDreams"
    local r,g,b,a = 1,1,1,0.8
    cairo_set_source_rgba (cr,r,g,b,a)
    cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
    cairo_set_font_size (cr,12)
    local xt,yt = position_text(cr,wx,xW,yW+10,1)
    cairo_move_to (cr,xt,yt)
    cairo_show_text (cr,wx)
    cairo_stroke (cr)
end

function draw_WindArrow(cr,x, y, length, bearing,radiusW)
    -- startpoint x, startpoint y, length of side, compass bearing
    local head_ratio = 1.05 -- ratio of side to overall length
    local head_angle = 0.02 -- proportion 0 - 0.5 (straight, at right angle to direction)
    
    local x1=x- (math.sin(bearing)*radiusW)
    local y1=y- (math.cos(bearing)*radiusW)
    --arrow body
    local angle = bearing
    local x0 = x1 + (math.sin(angle) * length)
    local y0 = y1 + (math.cos(angle) * length)
    local xtext = x1 + (math.sin(angle) * 0.25*length)
    local ytext = y1 + (math.cos(angle) * 0.25*length)

    --arrow head left
    angle = bearing - (head_angle * math.pi)
    x2 = x0 - (math.sin(angle) * length * head_ratio)
    y2 = y0 - (math.cos(angle) * length * head_ratio)

    --arrow head right
    angle = bearing + (head_angle * math.pi)
    x3 = x0 - (math.sin(angle) * length * head_ratio)
    y3 = y0 - (math.cos(angle) * length * head_ratio)
    
    start_x=(x0+x2+x3)/3
    start_y=(y0+y2+y3)/3
    
    cairo_set_source_rgba (cr,0,1,1,0.8)
    cairo_move_to (cr,start_x,start_y)
    cairo_line_to (cr,x2,y2)
    cairo_line_to (cr,x1,y1) 
    cairo_line_to (cr,x3,y3) 
    cairo_close_path (cr)
    cairo_fill(cr)
    cairo_stroke (cr)
    
    return true
end

--  display compass points
function draw_NESW(cr,x,y,rt,font_size)
    local compass={0,90,180,270}
    local cpoints={"N","E","S","W"}
    radiusW=rt+12
    
    for i = 1,4,1 do
        compass_point=-math.pi*(tonumber(compass[i]))/180
        local x1=x - (math.sin(compass_point)*radiusW)
        local y1=y - (math.cos(compass_point)*radiusW)
        local t = cpoints[i]
        print_text(cr,t,x1,y1,1,font_size)
    end
end

--  draw compass rose graduations
function draw_marks(cr,x,y,r)
    local angle=0
    local inner=r-2
    local outer=r+2

    local r,g,b,a=1,1,1,0.5
    cairo_set_source_rgba (cr,r,g,b,a)
    cairo_set_line_width(cr, 1)

    for i = 0,36,1 do   -- draw small ticks, every 10 deg
        compass_arc=(-2*math.pi/360)*angle
        local x0 = x - (math.sin(compass_arc) * inner)
        local y0 = y - (math.cos(compass_arc) * inner)
        local endx = x - (math.sin(compass_arc) * outer)
        local endy = y - (math.cos(compass_arc) * outer)
        
        if ( (i/3) - math.floor(i/3) ~= 0 ) then -- don't draw every third tick
            cairo_move_to (cr,x0,y0)
            cairo_line_to(cr,endx,endy)
            cairo_stroke(cr)
        end
        angle=angle+10
    end
    
    angle=0 -- re-set angle
    
    for i = 0,12,1 do       -- draw large ticks, every 30 deg
        compass_arc=(-2*math.pi/360)*angle
        x0 = x - (math.sin(compass_arc) * (inner-5))
        y0 = y - (math.cos(compass_arc) * (inner-5))
        endx = x - (math.sin(compass_arc) * outer)
        endy = y - (math.cos(compass_arc) * outer)
        
        cairo_move_to (cr,x0,y0)
        cairo_line_to(cr,endx,endy)
        cairo_stroke(cr)
        angle=angle+30
    end
end

function print_text(cr,t,xT,yT,posT,font_size)
     --  align text, using text area extents
    -- posT:        0 = none
    --              1 = align both
    --              2 = horizontal
    --              3 = vertical
    --              4 = left
    cairo_set_font_size (cr,font_size)
    if ( posT == 0 ) then
        xt = xT
        yt = yT
    else
        xt,yt = position_text(cr,t,xT,yT,posT)
    end
    cairo_move_to (cr,xt,yt)
    cairo_show_text (cr,t)
    cairo_stroke (cr)
end

function position_text(cr,t,text_x,text_y,pos)
    -- adjust text position
    -- get text area (x_bearing,y_bearing,width,height,x_advance,y_advance)
    te=cairo_text_extents_t:create()
    cairo_text_extents(cr,t,te)
    xtext = text_x
    ytext = text_y
    
    if ( pos == 1 ) then    -- centre text
        xtext = text_x - te.width/2
        ytext = text_y + te.height/2
    elseif ( pos == 2 ) then    -- horizontal align
        xtext = text_x - te.width/2
    elseif ( pos == 3 ) then    -- vertical align
        ytext = text_y + te.height/2
    elseif ( pos == 4 ) then    -- set right edge of text to pos
        xtext = text_x - te.width
    end

    return xtext,ytext
end

lua-weather.sh:

#!/bin/bash
#
## lua-weather.sh by <damo> July 2016
## Adapted from bunsenweather.sh, which was based on ideas from 
## weatherbang.sh version 1.0, 2013 by Ryan Fantus
##
## Requires:
##          'jq' (sudo apt-get install jq);
##          API Key from http://openweathermap.org/api
##
## USAGE: Call this script from Conky with ( replace "<t>" with the update interval)
##          ${execpi <t> /path/to/lua-weather.sh [location]}


#### User configurables:  ##############################################

# Get API KEY by registering for one at http://openweathermap.org/api
api="xxxxxxxxxxxxxxxx"

# Either set the location manually here, or by passing it as a script parameter in the Conky.
# "yourlocation" must be a name (which doesn't have spaces), or a numeric id.
#
# id's can be obtained from http://bulk.openweathermap.org/sample/city.list.json.gz
# Download and extract the json file, then simply search for an id with grep. 
#   For example:   grep "New York" city.list.json
#
# If $place is not set, then the script attempts to get a geolocation from the IP address.

#place="$1"              # Get $place from script parameter.
place="4787519"   # Uncomment and add name or id. NB If the name has spaces, then you must use the id.

# Choose fahrenheit/Imperial or Celcius/metric:
#metric='imperial'
metric='imperial'

# data file
datafile="/home/manuel/weather.txt"

#########################################################################
connectiontest() {
    local -i i attempts=${1-0}
    for (( i=0; i < attempts || attempts == 0; i++ )); do
        if wget -O - 'http://ftp.debian.org/debian/README' &> /dev/null; then
            return 0
        fi
        if (( i == attempts - 1 )); then # if last attempt
            return 1
        fi
    done
}

placeholder() {
    if (( $1 == 1 )) &>/dev/null;then
        echo "No internet connection"
        echo "Weather information unavailable"
    else
        echo "No API key"
        echo "Weather information unavailable"
    fi
}

if [[ $metric == metric ]] &>/dev/null;then
    scaleT="°C"
    scaleV="m/s"
else
    scaleT="°F"
    scaleV="mph"
fi

if [[ -z "$api" ]] &>/dev/null;then
    placeholder 0 && exit 1
else
    connectiontest 10
    
    # If latlong is preferred then don't set a value for $place
    if (( $? == 0 )) &>/dev/null;then
        if [[ -z $place ]] &>/dev/null;then
            # Geolocate IP:
            ipinfo=$(curl -s ipinfo.io)
            latlong=$(echo "$ipinfo" | jq -r '.loc')
            # Parse the latitude and longitude
            lat=${latlong%,*}
            long=${latlong#*,}
            location="lat=$lat&lon=$long"
        else
            # check if numeric id, or placename is being used
            [[ ${place##*[!0-9]*} ]] &>/dev/null && location="id=$place" || location="q=$place"
        fi

        # get json data from openweathermap:
        weather=$(curl -s http://api.openweathermap.org/data/2.5/weather\?APPID=$api\&"$location"\&units=$metric)
        city=$(echo "$weather" | jq -r '.name') # In case location has spaces in the name
        weather_desc=$(echo "$weather" | jq -r '.weather[0].description')   # In case description has spaces in the name

        # load values into array:
        all=($(echo "$weather" | jq -r '.coord.lon,.coord.lat,.weather[0].main,.main.temp,.main.pressure,.main.temp_min,.main.temp_max,.wind.speed,.wind.deg,.clouds.all,.sys.sunrise,.sys.sunset'))
        #                   ARRAY INDEX  0          1          2                3          4              5              6              7           8         9           10           11

        longitude=$(printf '%06.1f' ${all[0]})
        latitude=$(printf '%+.1f' ${all[1]})
        condition="${all[2]}"
        temperature=$(printf '%+.1f%s' ${all[3]} $scaleT)
        pressure=$(printf '%.f %s' ${all[4]} mb)
        temperature_min=$(printf '%+.1f%s' ${all[5]} $scaleT)
        temperature_max=$(printf '%+.1f%s' ${all[6]} $scaleT)
        cloud_cover=$(printf '%d%s' ${all[9]} %)
        sunrise=$(date -d @${all[10]} +"%R")
        sunset=$(date -d @${all[11]} +"%R")
        description="$weather_desc"
        winddir=$(printf '%3.f%s' ${all[8]} °)
        
        winddir=${all[8]}
        echo ${winddir%.*} > "$datafile"
        windspeed=$(echo ${all[7]}*1.9 | bc)
        windspeed=$(printf '%.1f %s' ${all[7]} $scaleV)
        echo "$windspeed" >> "$datafile"
        echo "$sunrise" | sed 's/://' >> "$datafile"
        echo "$sunset" | sed 's/://'>> "$datafile"
        temp_degrees=$(printf '%.1f' ${all[3]})
        echo "$temp_degrees" >> "$datafile"
        echo "$city" >> "$datafile" 
        echo "$description" >> "$datafile"

    else
        placeholder 1
    fi
fi

exit

settings.lua:

function conky_vars()

        
    border_COLOR = "green" --options are green, blue, black, orange or default
    
    use_FONT = "caviar dreams"
    -- https://www.dafont.com/zekton.font
    
end

--[[
#########################
# conky-system-lua-V3   #
# by +WillemO @wim66    #
# v1.5 23-dec-17        #
#                       #
#########################
]]

2018-03-08-15-23-06_scrot.th.png

Offline

Board footer

Powered by FluxBB