Logansfury wrote: ⤴Wed Feb 07, 2024 1:26 pm Welcome Back, Bleys
wetter.sh
wetter.luaCode: Select all
#!/bin/sh #openweathermap RSS tool conky # # # Bleys 2022 # key="xxxxxxxxxxxxxxxxxxxxxxxxxxx" #persönlicher Key. Hier einmal Account anlegen: https://openweathermap.org/api und key erzeugen lat="36.134452" #Längengrad der eigenen Location lon="-115.283180" #Breitengrad der eigenen Location wetter=$(curl -s 'api.openweathermap.org/data/2.5/weather?lat='$lat'&lon='$lon'&units=imperial&appid='$key 2>/dev/null) text=$(echo $wetter | jq -r '.weather[0].description') tp=$( printf "%.1f" $(echo $wetter | jq -r '.main.temp')) wind=$( printf "%.1f" $(echo $wetter | jq -r '.wind.speed')) lf=$(echo $wetter | jq -r '.main.humidity') icon=$(echo $wetter | jq -r '.weather[0].icon') stadt=$(echo $wetter | jq -r '.name') luftdruck=$(echo $wetter | jq -r '.main.pressure') boeen=$(echo $wetter | jq -r '.wind.gust') sunrise=$(date +%l:%M%p -d @$(echo $wetter | jq -r '.sys.sunrise')) sunset=$(date +%l:%M%p -d @$(echo $wetter | jq -r '.sys.sunset')) aktualisiert=$(date +%l:%M%p) deg=$(echo $wetter | jq -r '.wind.deg') echo $text','$tp','$wind','$lf','$icon','$sunrise','$sunset','$aktualisiert','$luftdruck','$kmhboeen','$deg
Code: Select all
--[[ 2023 Bleys ]] require 'cairo' require "imlib2" home_path = os.getenv ('HOME') function rgb_to_rgba(color,alpha) if color == nil then color=0xFF0000 end if alpha == nil then alpha=1 end return ((color / 0x10000) % 0x100) / 255., ((color / 0x100) % 0x100) / 255., (color % 0x100) / 255., alpha end function write_text(cr, x, y, text, f) --write_text(cr, x, y, text, {}) --font attributes (Schriftattribute zuweisen oder default Werte annehmen) local font=f.font or "Neon 80s" local size=f.size or 12 local align=f.align or 'l' local bold=f.bold or false local ital=f.italic or false local color=f.color or "0xffffff" local slant=CAIRO_FONT_SLANT_NORMAL if ital then slant=CAIRO_FONT_SLANT_ITALIC end local weight=CAIRO_FONT_WEIGHT_NORMAL if bold then weight=CAIRO_FONT_WEIGHT_BOLD end --Text Size (Textgröße für die Plazierung bestimmen.) local x_a=0 local y_a=0 local te = cairo_text_extents_t:create() tolua.takeownership(te) cairo_select_font_face (cr, font, slant, weight) cairo_set_font_size (cr, size) cairo_text_extents (cr, text, te) --Text Position if align=='c' then x_a = -(te.width/2+te.x_bearing) y_a = -(te.height/2+te.y_bearing) end if align=='r' then x_a = -(te.width+te.x_bearing) end --Schadow 1 Pixel (Schatten für den Text um 1 Pixel versetzt) cairo_set_source_rgba(cr, rgb_to_rgba(0x000000,1)) cairo_move_to (cr, x+1+x_a, y+1+y_a) cairo_show_text (cr, text) cairo_stroke(cr) -- Now Text on Top (nun den Text oben drauf) cairo_set_source_rgba(cr, rgb_to_rgba(color,1)) cairo_move_to (cr, x+x_a, y+y_a) cairo_show_text (cr, text) cairo_stroke(cr) end function mysplit (inputstr, sep) if sep == nil then sep = "," end local t={} for str in string.gmatch(inputstr, "([^"..sep.."]+)") do table.insert(t, str) end return t end function fDrawImage(cr,path,xx,yy,ww,hh,arc) cairo_save (cr) local img = cairo_image_surface_create_from_png(path) local w_img, h_img = cairo_image_surface_get_width(img), cairo_image_surface_get_height(img) cairo_translate (cr, xx, yy) if arc then cairo_rotate (cr, arc) end cairo_scale (cr, ww/w_img, hh/h_img) cairo_set_source_surface (cr, img, -w_img/2, -h_img/2) cairo_paint (cr) cairo_surface_destroy (img) collectgarbage () cairo_restore (cr) end function conky_main() if conky_window==nil then return end 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) local updates=conky_parse('${updates}') update_num=tonumber(updates) if update_num>4 then wetter = mysplit (conky_parse('${execi 60 sh '..home_path..'/.conky/wetter.sh}')) --1-text, 2-temperatur, 3-wind, 4-humidity,5-icon, 6-sunrise, 7-sunset,8-updated,9-air pressure,10-gust,11-deg -- Wetter (Weather) if wetter[1]~=nil then write_text(cr, 20,20,wetter[1], {align="l", size=14, bold=true, color="0xff0000"}) write_text(cr, 20,70,"Humidity: ", {align="l", size=12, color="0xff0000"}) write_text(cr, 120,70,wetter[4].."%", {align="r", size=12, color="0xffffff"}) write_text(cr, 20,86,"Air pressure: ", {align="l", size=12, color="0xff0000", font="Neon 80s"}) write_text(cr, 100,86,wetter[9].." hPa", {size=12, color="0xffffff"}) write_text(cr, 20,102,"Wind Spd: ",{align="l", size=12, color="0xff0000", font="Neon 80s"}) write_text(cr, 100,102, " (Gusts: ",{size=12, color="0xff0000", font="Neon 80s"}) write_text(cr, 82,102,wetter[3],{align="l", font="Neon 80s", size=12, color="0xffffff"}) write_text(cr, 144,102,wetter[10],{align="l", font="Neon 80s", size=12, color="0xffffff"}) write_text(cr, 172,102, ")", {align="l", size=12, color="0xff0000", font="Neon 80s"}) write_text(cr, 178,102,"mph", {align="l", size=12, color="0xffffff", font="Neon 80s"}) write_text(cr, 20,50,wetter[2].."°F", {font="Neon 80s", bold=false, size=20, align="l", color="0xffffff"}) write_text(cr, 20,50,wetter[2].."°F", {font="Neon 80s", bold=false, size=20, align="l", color="0xffffff"}) write_text(cr, 326,146,"updated: ", {font="Neon 80s", size=10, color = "0xff0000", align="r"}) write_text(cr, 368,146,wetter[8], {font="Neon 80s", bold=false, size=10, align="r"}) write_text(cr, 20,136,"Sunrise:", {align="l", font="Neon 80s", size=12, color="0xff0000"}) write_text(cr, 20,152,"Sunset:", {align="l", font="Neon 80s", size=12, color="0xff0000"}) write_text(cr, 64,136,wetter[6], {font="Neon 80s", size=12}) write_text(cr, 64,152,wetter[7], {font="Neon 80s", size=12}) write_text(cr, 20,120, "Wind Dir:", {font="Neon 80s", size=12, color="0xff0000"}) write_text(cr, 82,120,wetter[10].."°",{align="l", font="Neon 80s", size=12, color="0xffffff"}) -- {exec echo $(awk 'BEGIN{dir[1]="N";dir[2]="NE";dir[3]="E";dir[4]="SE";dir[5]="S";dir[6]="SW";dir[7]="W";dir[8]="NW";for(i in dir) if(i*45-45<$wetter[10] && $wetter[10]<=i*45) print dir[i]}')} > /home/logansfury/.conky/Bleys\ Weather/direction} fDrawImage(cr,home_path..'/.conky/wettericons/'..wetter[5]..'.png',312,40,116,80) -- Adapt path to your own paths end end cairo_surface_destroy(cs) cairo_destroy(cr) end[/code} [/quote]
Getting Conky weather icons from Bleys to work [SOLVED]
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
- Logansfury
- Level 6
- Posts: 1237
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Getting Conky weather icons from Bleys to work [SOLVED]
- Logansfury
- Level 6
- Posts: 1237
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Getting Conky weather icons from Bleys to work [SOLVED]
OK
I have got my deg variable recognized as wetter[11] will add the other three as 12-14.
Safari, Sogoodi!
I have got my deg variable recognized as wetter[11] will add the other three as 12-14.
Safari, Sogoodi!
- Logansfury
- Level 6
- Posts: 1237
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Getting Conky weather icons from Bleys to work [SOLVED]
Bleys can you please help me with a conversion script?
I got this to convert wind degrees number into an alphabetic direction
How could I use this in the script to apply the outcome of above to a variable I could then print onscreen along with the degree number. I would like degree and direction to both display please.
I got this to convert wind degrees number into an alphabetic direction
Code: Select all
${execpi 3600 echo "$(awk 'BEGIN{dir[1]="N";dir[2]="NE";dir[3]="E";dir[4]="SE";dir[5]="S";dir[6]="SW";dir[7]="W";dir[8]="NW";for(i in dir) if(i*45-45<$wetter[10] && $wetter[10]<=i*45) print dir[i]}')"}
Re: Getting Conky weather icons from Bleys to work [SOLVED]
this is much easier and more elegant to implement. wetter.lua, add 2 Lines after the fDrawImage line:
Code: Select all
local arc_deg = (2 * math.pi / 360) * wetter[11]
fDrawImage(cr,home_path..'/.conky/wettericons/arrow.png',76,80,16,16,arc_deg)
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
- Logansfury
- Level 6
- Posts: 1237
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Getting Conky weather icons from Bleys to work [SOLVED]
This does look nice, but I was hoping to get an alphabetical readout following the degrees display, such as:Bleys wrote: ⤴Wed Feb 07, 2024 5:26 pmthis is much easier and more elegant to implement. wetter.lua, add 2 Lines after the fDrawImage line:
find an arrow that suits you, name is arrow.png and place it inside Weather Icon Folder. I made a simple one with gimp:Code: Select all
local arc_deg = (2 * math.pi / 360) * wetter[11] fDrawImage(cr,home_path..'/.conky/wettericons/arrow.png',76,80,16,16,arc_deg)
arrow.png
Screen Capture_select-area_20240207222640.jpg
Do not forget: As with placing, fDrawImage rotates images around the center of the image.
Code: Select all
Wind Dir: 90° E
Re: Getting Conky weather icons from Bleys to work [SOLVED]
You're worse at explaining what you want. You said that the bash script was started by something else, not by conky. If i knew it was started by conky, then you didn't have to save it to a text file first, but just echo it to the terminal and execute the script withLogansfury wrote: ⤴Wed Feb 07, 2024 5:42 pm Koentje had a great idea, have conky launch a bash script that prints the outcome of the script to a text document, then have conky read the text document and display the result.
${execp script}
. P for PASTE output to conky.- Logansfury
- Level 6
- Posts: 1237
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Getting Conky weather icons from Bleys to work [SOLVED]
Probably an Italian-American thing >.<
Plus pulling all nighters, my mind is a void sometimes.
Lemme see how much of this I can pull off without needing help formatting.
- Logansfury
- Level 6
- Posts: 1237
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Getting Conky weather icons from Bleys to work [SOLVED]
Actually I am already at a loss. I have a terminal style script to convert degrees to direction, How do I get the conky variable wetter[11]'s contents run by the script?Logansfury wrote: ⤴Wed Feb 07, 2024 5:53 pmProbably an Italian-American thing >.<
Plus pulling all nighters, my mind is a void sometimes.
Lemme see how much of this I can pull off without needing help formatting.
I have two conversion scripts to work with:
Code: Select all
wetter[11]=$(awk 'BEGIN{dir[1]="N";dir[2]="NE";dir[3]="E";dir[4]="SE";dir[5]="S";dir[6]="SW";dir[7]="W";dir[8]="NW";for(i in dir) if(i*45-45<$1 && $1<=i*45) print dir[i]}')
Code: Select all
-- degrees to direction
${execpi 3600 echo "$(awk 'BEGIN{dir[1]="N";dir[2]="NE";dir[3]="E";dir[4]="SE";dir[5]="S";dir[6]="SW";dir[7]="W";dir[8]="NW";for(i in dir) if(i*45-45<$wetter[11] && $wetter[11]<=i*45) print dir[i]}')"}
Re: Getting Conky weather icons from Bleys to work [SOLVED]
i'll think about it tomorrow. i'm done with the world for today
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
- Logansfury
- Level 6
- Posts: 1237
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Getting Conky weather icons from Bleys to work [SOLVED]
Have a wonderful evening Bleys! That compass image is beautiful!!
If I can manage to get the alphabetic conversion done, I think I would like to use that on one linux box, and the compass you just displayed on my 2nd box
Perhaps tomorrow you can set me up with that image file?
Take care
Re: Getting Conky weather icons from Bleys to work [SOLVED]
Ok.. I probably wouldn't have had any peace of mind until I had a solution. So then, without much description. Everything that generates the output is outlined in red.
Addition: To cover N (North) right add this line:
bevor the last write_text
Addition: To cover N (North) right add this line:
Code: Select all
if dir==17 then dir = 1 end
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
- Logansfury
- Level 6
- Posts: 1237
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Getting Conky weather icons from Bleys to work [SOLVED]
Coming along nicely. I am working with a pair of these, One closer to original for comparison:
Re: Getting Conky weather icons from Bleys to work [SOLVED]
Ups.. The arrow must be reversed. This way it points in the direction from which the wind is coming. Just rotate the Arrow 180°
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
- Logansfury
- Level 6
- Posts: 1237
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Getting Conky weather icons from Bleys to work [SOLVED]
You are like unto a forum GOD That is exactly what I wanted thank you! I do also very much like your compass art and would like to have that sometime tomorrow for linux box #2Bleys wrote: ⤴Wed Feb 07, 2024 6:56 pm Ok.. I probably wouldn't have had any peace of mind until I had a solution. So then, without much description. Everything that generates the output is outlined in red.
Screen Capture_select-area_20240207235424.jpg
Addition: To cover N (North) right add this line:bevor the last write_textCode: Select all
if dir==17 then dir = 1 end
I wish you well-deserved rest
- Logansfury
- Level 6
- Posts: 1237
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Getting Conky weather icons from Bleys to work [SOLVED]
It looks awesome to me! The arrow is pointing to SW so I'm happy. When I swapped it pointed to NE (Yes I am keeping your awesome arrow )
- Logansfury
- Level 6
- Posts: 1237
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Getting Conky weather icons from Bleys to work [SOLVED]
I have 2 versions of your weather conky prepared. One to possibly go in my Minimalis, the other for the other linux box, which I have formatted to make room for the compass artwork.
- Logansfury
- Level 6
- Posts: 1237
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Getting Conky weather icons from Bleys to work [SOLVED]
Hey Bleys,
When you have time please look at this. I noted in my wetter.lua that the update symbol in your conky was displaying like a rectangle with symbols in it. I went to your site with the original weather only documents, and noted you had Font Awesome as the font for that symbol. I found a font awesome download, and it has files full of symbols, but when I open it in gimp and type out its only alpha-numeric chars. Then I noticed that after loading the font, my display in text editor of wetter.lua showed the same 90 degree turning arrows forming a box as you had in your first conky pictures! However, while I have this update symbol in the .lua, it is NOT showing on the widget. Note the image below with arrows pointing to the pertinent items. Do you know what I need to do to get conky to display like my text editor does?
Here is how it showed before I installed the font:
When you have time please look at this. I noted in my wetter.lua that the update symbol in your conky was displaying like a rectangle with symbols in it. I went to your site with the original weather only documents, and noted you had Font Awesome as the font for that symbol. I found a font awesome download, and it has files full of symbols, but when I open it in gimp and type out its only alpha-numeric chars. Then I noticed that after loading the font, my display in text editor of wetter.lua showed the same 90 degree turning arrows forming a box as you had in your first conky pictures! However, while I have this update symbol in the .lua, it is NOT showing on the widget. Note the image below with arrows pointing to the pertinent items. Do you know what I need to do to get conky to display like my text editor does?
Here is how it showed before I installed the font:
- Logansfury
- Level 6
- Posts: 1237
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Getting Conky weather icons from Bleys to work [SOLVED]
I just saw something else intriguing in your work! In this conky:
I note a sunrise font symbol by the 08:23 time and a sunset font symbol next to 17:03 time.
May I have the font for those please?
I note a sunrise font symbol by the 08:23 time and a sunset font symbol next to 17:03 time.
May I have the font for those please?
Re: Getting Conky weather icons from Bleys to work [SOLVED]
https://www.dafont.com/de/weather.fontLogansfury wrote: ⤴Thu Feb 08, 2024 2:31 am
I note a sunrise font symbol by the 08:23 time and a sunset font symbol next to 17:03 time.
May I have the font for those please?
After installing new Fonts:
Code: Select all
sudo fc-cache
I am currently traveling with my Notbook. The Compass picture will come this afternoon.
Last edited by Bleys on Thu Feb 08, 2024 5:27 am, edited 1 time in total.
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
- Logansfury
- Level 6
- Posts: 1237
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Getting Conky weather icons from Bleys to work [SOLVED]
Got em! Thank you so much! What about the Font Awesome? I downloaded one that corrected the output and showed the flowing arrows in the .lua but its still displaying as a blank rectangle on screenBleys wrote: ⤴Thu Feb 08, 2024 5:13 amhttps://www.dafont.com/de/weather.fontLogansfury wrote: ⤴Thu Feb 08, 2024 2:31 am
I note a sunrise font symbol by the 08:23 time and a sunset font symbol next to 17:03 time.
May I have the font for those please?
After installing new Fonts:and restart conky or just rebootCode: Select all
sudo fc-cache