Getting Conky weather icons from Bleys to work [SOLVED]

Add functionality to your desktop
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Post Reply
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Getting Conky weather icons from Bleys to work [SOLVED]

Post by Logansfury »

Bleys wrote: Tue Jan 23, 2024 1:28 am Scripte: https://gist.github.com/rdschmidt/c1ed9 ... 087fa2492a
Hello Bleys!

I have visited your github and attempted to download this. I was able to copy all provided code, but the Open Weather map URL to the icons is actually pointed to
https://gist.github.com/rdschmidt/url

Which leads to a 404 page. Can you please restore link the the icons?

Thank you,

Logan
Last edited by Logansfury on Wed Feb 07, 2024 9:14 am, edited 2 times in total.
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Conky Showoff thread 2024

Post by Bleys »

Logansfury wrote: Sat Feb 03, 2024 10:18 pm
Which leads to a 404 page. Can you please restore link the the icons?
That's probably the better solution:
WeatherIcons_naming.jpg
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Conky Showoff thread 2024

Post by Logansfury »

Bleys wrote: Sun Feb 04, 2024 12:53 am
Logansfury wrote: Sat Feb 03, 2024 10:18 pm
Which leads to a 404 page. Can you please restore link the the icons?
That's probably the better solution:
WeatherIcons_naming.jpg
Thank you for the list of proper names :) I'm downloading the icon pack now!
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Conky Showoff thread 2024

Post by Logansfury »

Hey Bleys,

Once these icons are downloaded (and what happened to 05d/n - 08d/n? is the set incomplete missing fog and haze etc?) what is their proper file path for the conky to use them please?
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Conky Showoff thread 2024

Post by Bleys »

Logansfury wrote: Sun Feb 04, 2024 1:06 am Hey Bleys,

Once these icons are downloaded (and what happened to 05d/n - 08d/n? is the set incomplete missing fog and haze etc?) what is their proper file path for the conky to use them please?
The original naming schema: https://openweathermap.org/weather-conditions openweather has no icons for 05 and 08
The appropriate weather icon is displayed in this line:

Code: Select all

        fDrawImage(cr,home_path..'/.conky/wettericons/'..wetter[5]..'.png',108,50,70,48) --(cr,path,xx,yy,ww,hh,arc)
so in my conky in /home/<user>/.conky/wettericons/xxx.png
simply adapt to your own paths
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Conky Showoff thread 2024

Post by Bleys »

wetter.sh line 16:

Code: Select all

	icon=$(echo $wetter | jq -r '.weather[0].icon') 
This line in the wetter.sh fetches the current icon name from the json file. In the LUA script, the name then appears in the array variable wetter[5]
Screen Capture_select-area_20240204062202.jpg
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Conky Showoff thread 2024

Post by Bleys »

Oops... forgotten. jq must be installed! With the help of jq the json output is parsed

Code: Select all

sudo apt install jq
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Conky Showoff thread 2024

Post by Logansfury »

Bleys wrote: Sun Feb 04, 2024 1:19 am The original naming schema: https://openweathermap.org/weather-conditions openweather has no icons for 05 and 08
The appropriate weather icon is displayed in this line:

Code: Select all

        fDrawImage(cr,home_path..'/.conky/wettericons/'..wetter[5]..'.png',108,50,70,48) --(cr,path,xx,yy,ww,hh,arc)
so in my conky in /home/<user>/.conky/wettericons/xxx.png
simply adapt to your own paths
That's an easy enough path for me to emulate, thank you. I did a google image search for openweathermap icons and this came up on deviant art:

Image

It turned out to be a free download of icons, I nabbed them all.
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Conky Showoff thread 2024

Post by Logansfury »

Bleys wrote: Sun Feb 04, 2024 1:27 am Oops... forgotten. jq must be installed! With the help of jq the json output is parsed

Code: Select all

sudo apt install jq
I have done the terminal cmd and it installed fine. I swapped the latitude/longitude coords for Las Vegas, NV. I have made a wettericons directory under .conky. However when I launch the conkyrc, I just see a blank horizontal frame appear and immediately dissapear.

What other edits are necessary to get this visible?
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Conky Showoff thread 2024

Post by Bleys »

Logansfury wrote: Sun Feb 04, 2024 1:41 am
What other edits are necessary to get this visible?
post weather.sh and LUA Script

Here I have the scripts for weather only: https://gist.github.com/rdschmidt/3e903 ... 5e313ea9b7
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Conky Showoff thread 2024

Post by Logansfury »

Bleys wrote: Sun Feb 04, 2024 1:57 am
Logansfury wrote: Sun Feb 04, 2024 1:41 am
What other edits are necessary to get this visible?
post weather.sh and LUA Script
Here you are :)

wetter.sh

Code: Select all

#!/bin/sh
#openweathermap RSS tool conky
#
#
# Bleys 2022
#
key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" #persönlicher Key. Hier einmal Account anlegen: https://openweathermap.org/api und key erzeugen
lat="36.169941" #Längengrad der eigenen Location 
lon="-115.139832" #Breitengrad der eigenen Location

		wetter=$(curl -s 'api.openweathermap.org/data/2.5/weather?lat='$lat'&lon='$lon'&lang=de&units=metric&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 +%H:%M -d @$(echo $wetter | jq -r '.sys.sunrise'))
        sunset=$(date +%H:%M -d @$(echo $wetter | jq -r '.sys.sunset'))
        aktualisiert=$(date +%H:%M)

echo $text','$tp','$wind','$lf','$icon','$sunrise','$sunset','$aktualisiert
vvr.lua:

Code: Select all

--[[
2023 Bleys
]]

settings_table = {

 {
   name='cpu',             arg='cpu1',
    max=100,
    bg_color=0xffffff,      bg_alpha=0.3,
    fg_color=0xffffff,      fg_alpha=0.8,
    hand_color=0x8B008B,    hand_alpha=0.9,
    x=6,                  y=250,
    width=17,                height=60,
    bar=1,                  pos='vertical',
  },
  {
    name='cpu',             arg='cpu2',
    max=100,
    bg_color=0xffffff,      bg_alpha=0.3,
    fg_color=0xffffff,      fg_alpha=0.8,
    hand_color=0x8B008B,    hand_alpha=0.9,
    x=24,                  y=250,
    width=17,                height=60,
    bar=1,                  pos='vertical',
  },
  {
    name='cpu',             arg='cpu3',
    max=100,
    bg_color=0xffffff,      bg_alpha=0.3,
    fg_color=0xffffff,      fg_alpha=0.8,
    hand_color=0x8B008B,    hand_alpha=0.9,
    x=42,                  y=250,
    width=17,                 height=60,
    bar=1,                  pos='vertical',
  },
  {
    name='cpu',             arg='cpu4',
    max=100,
    bg_color=0xffffff,      bg_alpha=0.3,
    fg_color=0xffffff,      fg_alpha=0.8,
    hand_color=0x8B008B,    hand_alpha=0.9,
    x=60,                  y=250,
    width=17,                 height=60,
    bar=1,                  pos='vertical',
  },
  {
    name='cpu',             arg='cpu5',
    max=100,
    bg_color=0xffffff,      bg_alpha=0.3,
    fg_color=0xffffff,      fg_alpha=0.8,
    hand_color=0x8B008B,    hand_alpha=0.9,
    x=78,                  y=250,
    width=17,                 height=60,
    bar=1,                  pos='vertical',
  },
  {
    name='cpu',             arg='cpu6',
    max=100,
    bg_color=0xffffff,      bg_alpha=0.3,
    fg_color=0xffffff,      fg_alpha=0.8,
    hand_color=0x8B008B,    hand_alpha=0.9,
    x=96,                  y=250,
    width=17,                 height=60,
    bar=1,                  pos='vertical',
  },
  {
    name='cpu',             arg='cpu7',
    max=100,
    bg_color=0xffffff,      bg_alpha=0.3,
    fg_color=0xffffff,      fg_alpha=0.8,
    hand_color=0x8B008B,    hand_alpha=0.9,
    x=114,                  y=250,
    width=17,                 height=60,
    bar=1,                  pos='vertical',
  },
  {
    name='cpu',             arg='cpu8',
    max=100,
    bg_color=0xffffff,      bg_alpha=0.3,
    fg_color=0xffffff,      fg_alpha=0.8,
    hand_color=0x8B008B,    hand_alpha=0.9,
    x=132,                  y=250,
    width=17,                 height=60,
    bar=1,                  pos='vertical',
  },
  {
    name='battery_percent',             arg='BAT0',
    max=100,
    bg_color=0xffffff,      bg_alpha=0.3,
    fg_color=0xffffff,      fg_alpha=0.8,
    hand_color=0x8B008B,    hand_alpha=0.9,
    x=10,                  y=759,
    width=140,                 height=5,
    bar=1,                  
  },

  {
    name='memperc',
    arg='',
    max=100,
    bg_color=0xffffff,      bg_alpha=0.3,
    fg_color=0x1e90ff,      fg_alpha=1.0,
    hand_color=0x8B008B,    hand_alpha=0.9,
    x=112,      y=300,       radius=30,
    thickness=7,
    start_angle=0,          end_angle=270,
    typ=1
  },
  {
    name='swapperc',
    arg='',
    max=100,
    bg_color=0xffffff,      bg_alpha=0.3,
    fg_color=0xffffff,      fg_alpha=1.0,
    hand_color=0x8B008B,    hand_alpha=0.9,
    x=112,      y=300,       radius=22,
    thickness=7,
    start_angle=0,          end_angle=270,
    typ=1
  },
  
  {
    name='fs_used_perc',
    arg='/home',
    max=100,
    bg_color=0xffffff,      bg_alpha=0.3,
    fg_color=0xffffff,      fg_alpha=1.0,
    hand_color=0x8B008B,    hand_alpha=0.9,
    x=40,      y=300,       radius=22,
    thickness=7,
    start_angle=0,          end_angle=270,
    typ=1
  },
   {
    name='fs_used_perc',
    arg='/',
    max=100,
    bg_color=0xffffff,      bg_alpha=0.3,
    fg_color=0x1e90ff,      fg_alpha=1.0,
    hand_color=0x8B008B,    hand_alpha=0.9,
    x=40,      y=300,       radius=30,
    thickness=7,
    start_angle=0,          end_angle=270,
    typ=1
  },
{
    name='hwmon k10temp', --find your own sensor for CPU Temperature in /sys/class/hwmon
    arg='temp 1',
    max=95,
    bg_color=0xffffff,      bg_alpha=0.3,
    fg_color=0xffffff,      fg_alpha=1.0,
    hand_color=0x8B008B,    hand_alpha=0.9,
    x=10,      y=350,      
    thickness=5,
    width=140,              height=20,
    start_angle=15,          end_angle=345,
    reverse=1,                  typ=1

  },
 {
    name='hwmon hp', --find your own sensor for Fan in /sys/class/hwmon
    arg='fan 1',
    max=3500,
    bg_color=0xffffff,      bg_alpha=0.3,
    fg_color=0xffffff,      fg_alpha=1.0,
    hand_color=0x8B008B,    hand_alpha=0.9,
    x=10,      y=380,      
    thickness=5,
    width=140,              height=20,
    start_angle=15,          end_angle=345,
    reverse=1,              typ=1
  },
  
 {
    name='hwmon amdgpu', --find your own sensor for Vcore in /sys/class/hwmon
    arg='in 1',
    max=1.5,
    bg_color=0xffffff,      bg_alpha=0.3,
    fg_color=0xffffff,      fg_alpha=1.0,
    hand_color=0x8B008B,    hand_alpha=0.9,
    x=10,      y=410,      
    thickness=5,
    width=140,              height=20,
    start_angle=15,          end_angle=345,
    reverse=1,              typ=1
  },
 {
    name='hwmon nvme', --find your own sensor for SSD Temperature in /sys/class/hwmon
    arg='temp 1',
    max=90,
    bg_color=0xffffff,      bg_alpha=0.3,
    fg_color=0xffffff,      fg_alpha=1.0,
    hand_color=0x8B008B,    hand_alpha=0.9,
    x=10,      y=440,      
    thickness=5,
    width=140,              height=20,
    start_angle=15,          end_angle=345,
    reverse=1,              typ=1
  },

}

require 'cairo'
require "imlib2"
require "math"
home_path = os.getenv ('HOME')


function rgb_to_rgba(color,alpha)
	return ((color / 0x10000) % 0x100) / 255., ((color / 0x100) % 0x100) / 255., (color % 0x100) / 255., alpha
end
function draw_bg(cr,color,alpha,typ) -- zeichne Hintergrund Conky Fenster / draw Conky Area Background
    local corner_r=0
    local bg_color=color 

    local bg_alpha=alpha
	local w=conky_window.width
	local h=conky_window.height
	cairo_set_source_rgba(cr,rgb_to_rgba(bg_color,bg_alpha))
	cairo_move_to(cr,corner_r,0)
	cairo_line_to(cr,w-corner_r,0)
	cairo_curve_to(cr,w,0,w,0,w,corner_r)
	cairo_line_to(cr,w,h-corner_r)
	cairo_curve_to(cr,w,h,w,h,w-corner_r,h)
	cairo_line_to(cr,corner_r,h)
	cairo_curve_to(cr,0,h,0,h,0,h-corner_r)
	cairo_line_to(cr,0,corner_r)
	cairo_curve_to(cr,0,0,0,0,corner_r,0)
	cairo_close_path(cr)
    if typ==1 then
	    cairo_fill(cr)
    else
        cairo_set_line_width(cr, 3)
        cairo_stroke(cr)
    end
end
function draw_elipse(cr,t,pt)
	local w,h=conky_window.width,conky_window.height	
	local xc,yc,ring_r,ring_w,sa,ea=pt['x'],pt['y'],pt['radius'],pt['thickness'],pt['start_angle'],pt['end_angle']
	local bgc, bga, fgc, fga=pt['bg_color'], pt['bg_alpha'], pt['fg_color'], pt['fg_alpha']
    local tick, tick_a=pt['hand_color'], pt['hand_alpha']
    local dir=pt['reverse']
	local angle_0=sa*(2*math.pi/360)-math.pi/2
	local angle_f=ea*(2*math.pi/360)-math.pi/2
	local t_arc=t*(angle_f-angle_0)
    local width=pt['width']
    local height=pt['height']

	-- background ring
    cairo_save (cr)
    cairo_translate (cr, xc + width / 2.0, yc + height / 2.0)
    cairo_scale (cr, width / 2.0, height / 2.0)
    cairo_arc (cr, 0.0, 0.0, 1.0, angle_0, angle_f)
    cairo_restore (cr) 
	cairo_set_source_rgba(cr,rgb_to_rgba(bgc,bga))
	cairo_set_line_width(cr,ring_w)
    cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND)
	cairo_stroke(cr)
	
	-- indicator ring)

    cairo_save (cr)
    cairo_translate (cr, xc + width / 2.0, yc + height / 2.0)
    cairo_scale (cr, width / 2.0, height / 2.0)
    if dir==1 then
        cairo_arc (cr, 0.0, 0.0, 1.0, angle_0, angle_0+t_arc)
    else
        cairo_arc (cr, 0.0, 0.0, 1.0,angle_f-t_arc,angle_f)
    end
    cairo_restore (cr) 
	cairo_set_source_rgba(cr,rgb_to_rgba(fgc,fga))
	cairo_set_line_width(cr,ring_w)
	cairo_stroke(cr)	
-- hand

    cairo_save (cr)
    cairo_translate (cr, xc + width / 2.0, yc + height / 2.0)
    cairo_scale (cr, width / 2.0, height / 2.0)
    if dir==1 then
        cairo_arc (cr, 0.0, 0.0, 1.0, angle_0+t_arc-0.01, angle_0+t_arc)
    else
        cairo_arc (cr, 0.0, 0.0, 1.0,angle_f-t_arc,angle_f-t_arc+0.01)
    end
    cairo_restore (cr) 
    cairo_set_source_rgba(cr,rgb_to_rgba(tick,tick_a))
	cairo_set_line_width(cr,ring_w)
	cairo_stroke(cr)
end
function draw_bar(cr,pct,pt)
    local bgc, bga, fgc, fga=pt['bg_color'], pt['bg_alpha'], pt['fg_color'], pt['fg_alpha']
    local tick, tick_a=pt['hand_color'], pt['hand_alpha']
    if pt['pos'] == "vertical" then
        local h=pct*pt['height']
    --  Background
        cairo_rectangle(cr, pt['x'], pt['y'], pt['width'], -pt['height'])
        cairo_set_source_rgba(cr,rgb_to_rgba(bgc,bga))
        cairo_fill(cr)
    --  Indicator
        cairo_rectangle(cr, pt['x'], pt['y'], pt['width'], -h)
        cairo_set_source_rgba(cr,rgb_to_rgba(fgc,fga))
        cairo_fill(cr)
    -- hand
        cairo_rectangle(cr, pt['x'], pt['y']-h, pt['width'], -2)
        cairo_set_source_rgba(cr,rgb_to_rgba(tick,tick_a))
        cairo_fill(cr)
    elseif pt['dir'] == "reverse" then
        local w=pct*pt['width']

    --  Background
        cairo_rectangle(cr, pt['x'], pt['y'], -pt['width'], pt['height'])
        cairo_set_source_rgba(cr,rgb_to_rgba(bgc,bga))
        cairo_fill(cr)
    --  Indicator
        cairo_rectangle(cr, pt['x'], pt['y'], -w, pt['height'])
        cairo_set_source_rgba(cr,rgb_to_rgba(fgc,fga))
        cairo_fill(cr)
    -- hand
        cairo_rectangle(cr, pt['x']-w, pt['y'], -2, pt['height'])
        cairo_set_source_rgba(cr,rgb_to_rgba(tick,tick_a))
        cairo_fill(cr)
    else
        local w=pct*pt['width']
    --  Background
        cairo_rectangle(cr, pt['x'], pt['y'], pt['width'], pt['height'])
        cairo_set_source_rgba(cr,rgb_to_rgba(bgc,bga))
        cairo_fill(cr)
    --  Indicator
        cairo_rectangle(cr, pt['x'], pt['y'], w, pt['height'])
        cairo_set_source_rgba(cr,rgb_to_rgba(fgc,fga))
        cairo_fill(cr)
    --  hand
        cairo_rectangle(cr, pt['x']+w, pt['y'], 2, pt['height'])
        cairo_set_source_rgba(cr,rgb_to_rgba(tick,tick_a))
        cairo_fill(cr)
    end
    cairo_stroke (cr)
end
function draw_ring(cr,t,pt)
	local w,h=conky_window.width,conky_window.height
	
	local xc,yc,ring_r,ring_w,sa,ea=pt['x'],pt['y'],pt['radius'],pt['thickness'],pt['start_angle'],pt['end_angle']
	local bgc, bga, fgc, fga=pt['bg_color'], pt['bg_alpha'], pt['fg_color'], pt['fg_alpha']
    local tick, tick_a=pt['hand_color'], pt['hand_alpha']
	local angle_0=sa*(2*math.pi/360)-math.pi/2
	local angle_f=ea*(2*math.pi/360)-math.pi/2
	local t_arc=t*(angle_f-angle_0)
    local dir=pt['rev']

	-- Draw background ring

	cairo_arc(cr,xc,yc,ring_r,angle_0,angle_f)
	cairo_set_source_rgba(cr,rgb_to_rgba(bgc,bga))
	cairo_set_line_width(cr,ring_w)
	cairo_stroke(cr)
	
	-- Draw indicator ring
    if dir==1 then
        cairo_arc (cr, xc, yc, ring_r,angle_f-t_arc,angle_f)
    else
	    cairo_arc(cr,xc,yc,ring_r,angle_0,angle_0+t_arc)
    end
	cairo_set_source_rgba(cr,rgb_to_rgba(fgc,fga))
	cairo_stroke(cr)	
    
    -- draw hand
    if dir==1 then
        cairo_arc(cr,xc,yc,ring_r,angle_f-t_arc,angle_f-t_arc+0.1)
    else
        cairo_arc(cr,xc,yc,ring_r,angle_0+t_arc-0.1,angle_0+t_arc)
    end
    cairo_set_source_rgba(cr,rgb_to_rgba(tick,tick_a))
	cairo_stroke(cr)	
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 "Noto Sans"
      local size=f.size or 10
      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)
        --y_a = -(te.height+te.y_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 add_network_traffic(iface, up, down, nzeiger)
  nzeiger=nzeiger+1
  if nzeiger == samples + 1 then nzeiger = 0 end
  up[nzeiger]  =tonumber(conky_parse(string.format('${%s %s}', 'upspeedf'  , iface)))
  down[nzeiger]=tonumber(conky_parse(string.format('${%s %s}', 'downspeedf', iface)))
  return up, down, nzeiger
end

function draw_network_chart(cr, iface, up, down, nzeiger, x, y, l, h)
  cairo_set_line_width(cr, 1)
  local _up, _down, _y
  local _zeiger = nzeiger + 1
  --Grundlinie zeichnen
  cairo_set_source_rgba(cr, rgb_to_rgba(0xffffff, 0.2))
  cairo_line_to(cr, x, y)
  cairo_line_to(cr, x+l, y)
  cairo_stroke(cr)
  --Maxlinien zeichnen
  cairo_set_source_rgba(cr, rgb_to_rgba(0xffffff, 0.6))
  cairo_line_to(cr, x, y-h)
  cairo_line_to(cr, x+l, y-h)
  cairo_stroke(cr)
  cairo_line_to(cr, x, y+h)
  cairo_line_to(cr, x+l, y+h)
  cairo_stroke(cr)

  for i = 0, samples, 1
  do
    if _zeiger > samples then _zeiger = 0 end
    if up[_zeiger] == nil then _up=0 else _up=up[_zeiger] end
    if _up < 0.1 then _up = 0.1 end
    if _up==0 then print(math.log10(_up*10)) end
    _y = math.floor(math.log10(_up*10)/6*h)
    _x = math.floor(l/samples*i)
    cairo_set_source_rgba(cr, rgb_to_rgba(0x04b404, 1))
    cairo_line_to(cr, x+_x, y-_y)
    _zeiger = _zeiger + 1
  end
  cairo_stroke(cr)
  _zeiger = nzeiger + 1
  for i = 0, samples, 1
  do
    if _zeiger > samples then _zeiger = 0 end
    if down[_zeiger] == nil then _down=0 else _down=down[_zeiger] end
    if _down < 0.1 then _down = 0.1 end
    _y = math.floor(math.log10(_down*10)/6*h)
    _x = math.floor(l/samples*i)
    cairo_set_source_rgba(cr, rgb_to_rgba(0x0101df, 1))
    cairo_line_to(cr, x+_x, y+_y)
    _zeiger = _zeiger + 1
  end
  cairo_stroke(cr)
end
function conky_main()
    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

    local 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
	local function setup(cr,pt)
		local str=''
		local value=0
		local elp=pt['reverse']
		str=string.format('${%s %s}',pt['name'],pt['arg'])
		str=conky_parse(str)
		
		value=tonumber(str)
		if value == nil then value = 0 end
        if value >= pt['max'] then value = pt['max'] end
		pct=value/pt['max']
		if pt['typ'] == 1 then
            if elp==1 then
                draw_elipse(cr,pct,pt)
            else
    		    draw_ring(cr,pct,pt)
            end
        else
            draw_bar(cr,pct,pt)
        end
	end

	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)
	wetter = mysplit (conky_parse('${execi 300 sh '..home_path..'/.conky/wetter.sh}')) --1-text, 2-temperatur, 3-wind, 4-luftfeuchtigkeit, 5-icon
	if update_num>5 then
        color=0x5a5a5a  alpha=0.2   typ=1
        draw_bg(cr,color,alpha,typ) -- Funktion Hintergrund Conky Bereich / Function Backgrounds Conky Area
        color=0xffffff  alpha=0.8   typ=2
		for i in pairs(settings_table) do
			    setup(cr,settings_table[i])
		end	

-- Wetter

        write_text(cr, 35,44,wetter[2].."°C", {font="Arial Black", bold=false, size=16, align="c"})
        fDrawImage(cr,home_path..'/.conky/wettericons/'..wetter[5]..'.png',108,50,70,48) --(cr,path,xx,yy,ww,hh,arc)
        write_text(cr, 76,26,wetter[1], {align="c", size=9}) --Text
        write_text(cr, 10,85,'rF: '..wetter[4].."%", {align="l", size=9})
        write_text(cr, 145,85,'Wind: '..wetter[3].."m/s", {align="r", size=9})
        write_text(cr, 10,66,"  ", {font="FontAwesome", size=10, align="l"})
        write_text(cr, 22,66,wetter[8], {font="Arial", bold=false, size=10, align="l"}) --zuletzt aktualisiert
        write_text(cr, 10, 103, "A", {font="Weather", size=18, align="l"})
        write_text(cr, 24, 100, wetter[6], {size=10, align="l"})
        write_text(cr, 132, 100, wetter[7], {size=10, align="r"})
        write_text(cr, 145, 103, "C", {font="Weather", size=18, align="r"})

-- Netzwerk
  --Anzahl gespeicherter Netzwerktraffikwerte für up und down
  samples = 300         
  local iface='wlp2s0' 
  local y=0 
  --up und downlink speed speichern
  if not up then 
    up = {}
    down = {}
    nzeiger = -1
  end
  up, down, nzeiger=add_network_traffic(iface, up,down,nzeiger)
  --draw_network_chart(cr, iface, up, down, nzeiger, x, y, l, h)
  draw_network_chart(cr, iface, up, down, nzeiger, 22, 498, 128, 16)


-- Text - Standard: write_text(cr, x, y, 'text'), {font="Noto Sans", size=10, align="l", bold=false, italic=false, color="0xffffff"}))

        write_text(cr, 82, 273, "RAM", {font="Dyuthi",  color="0x1e90ff", size=10})
        write_text(cr, 82, 282, "Swap", {font="Dyuthi", size=10})	 
        write_text(cr, 122, 296, conky_parse('${memperc}').."%", {color="0x1e90ff", align="r"})  
        write_text(cr, 122, 307, conky_parse('${swapperc}').."%", {align="r"})  
        write_text(cr, 30, 296, conky_parse('${fs_used_perc /}').."%", {color="0x1e90ff"})    
        write_text(cr, 30, 307, conky_parse('${fs_used_perc /home}').."%", {})     
        write_text(cr, 10, 272, "Sys", {font="Dyuthi",  color="0x1e90ff", size=10})
        write_text(cr, 538, 51, conky_parse('${fs_used /}'), {color="0x1e90ff"})
        write_text(cr, 10, 282, "Home", {font="Dyuthi", size=10})
        write_text(cr, 538, 73, conky_parse('${fs_used /home}'),{})
        write_text(cr, 75, 180, "Ryzen 5 7520U", {font="Dyuthi", size=14,  align="c"})	
        write_text(cr, 75, 160, os.date("%a")..". "..os.date("%d").." "..os.date("%B").." "..os.date("%Y"), {font="Dyuthi", size=14,  align="c"})	
        write_text(cr, 80, 350, "CPU", {font="Dyuthi", size=10, align="c", color="0x1e90ff"})	
        write_text(cr, 80, 380, "FAN", {font="Dyuthi", size=10, align="c", color="0x1e90ff"})
        write_text(cr, 80, 410, "vddnb", {font="Dyuthi", size=10, align="c", color="0x1e90ff"})
        write_text(cr, 80, 440, "SSD", {font="Dyuthi", size=10, align="c", color="0x1e90ff"})
        write_text(cr, 80, 360, conky_parse('${hwmon k10temp temp 1}').."°C", {size=9, align="c"})
        write_text(cr, 80, 390, conky_parse('${hwmon hp fan 1}'), {size=9, align="c"})
        write_text(cr, 80, 420, conky_parse('${hwmon amdgpu in 1}').."V", {size=9, align="c"})
        write_text(cr, 80, 450, conky_parse('${hwmon nvme temp 1 }').."°C", {size=9, align="c"})

        write_text(cr, 80, 786, conky_parse('${execi 7200 lsb_release -ds}'), {font="Dyuthi", size=14, align="c"})
        write_text(cr, 80, 798, conky_parse('${kernel}'), {font="Dyuthi", size=14, align="c"})
        write_text(cr, 75, 473, "Uptime: "..conky_parse('${uptime_short}'), {align="c"})

        write_text(cr, 10, 495, "⬆", {color="0x1e90ff"})
        write_text(cr, 10, 507, "⬇", {color="0x1e90ff"})
        write_text(cr, 10, 529, "⬇", {color="0x1e90ff"})
        write_text(cr, 10, 540, "⬆", {color="0x1e90ff"})
        write_text(cr, 66, 530, conky_parse('${downspeed wlp2s0}'), {align="r"})
        write_text(cr, 70, 530, "Total:", {color="0x1e90ff"})
        write_text(cr, 150, 530, conky_parse('${totaldown wlp2s0}'), {align="r"})
        write_text(cr, 66, 541, conky_parse('${upspeed wlp2s0}'), {align="r"})
        write_text(cr, 70, 541, "Total:", {color="0x1e90ff"})
        write_text(cr, 150, 541, conky_parse('${totalup wlp2s0}'), {align="r"})
        write_text(cr, 12, 555, "IP:", {color="0x1e90ff"})
        write_text(cr, 80, 551, conky_parse('${execi 7200 curl https://ipinfo.io/ip}'), {align="c"})
        write_text(cr, 10, 578, "Top CPU", {font="Dyuthi", italic=true, size=12, color="0x1e90ff"})
        write_text(cr, 10, 591, conky_parse('${top name 1}'), {})
        write_text(cr, 150, 591, conky_parse('${top cpu 1}')..'%', {align="r"})
        write_text(cr, 10, 602, conky_parse('${top name 2}'), {})
        write_text(cr, 150, 602, conky_parse('${top cpu 2}')..'%', {align="r"})
        write_text(cr, 10, 613, conky_parse('${top name 3}'), {})
        write_text(cr, 150, 613, conky_parse('${top cpu 3}')..'%', {align="r"})
        write_text(cr, 10, 624, conky_parse('${top name 4}'), {})
        write_text(cr, 150, 624, conky_parse('${top cpu 4}')..'%', {align="r"})
        write_text(cr, 10, 634, conky_parse('${top name 5}'), {})
        write_text(cr, 150, 635, conky_parse('${top cpu 5}')..'%', {align="r"})


        write_text(cr, 10, 652, "Top MEM", {font="Dyuthi", size=12, color="0x1e90ff"})
        write_text(cr, 10, 666, conky_parse('${top_mem name 1}'), {})
        write_text(cr, 150, 666, conky_parse('${top_mem mem 1}')..'%', {align="r"})
        write_text(cr, 10, 677, conky_parse('${top_mem name 2}'), {})
        write_text(cr, 150, 677, conky_parse('${top_mem mem 2}')..'%', {align="r"})
        write_text(cr, 10, 688, conky_parse('${top_mem name 3}'), {})
        write_text(cr, 150, 688, conky_parse('${top_mem mem 3}')..'%', {align="r"})
        write_text(cr, 10, 699, conky_parse('${top_mem name 4}'), {})
        write_text(cr, 150, 699, conky_parse('${top_mem mem 4}')..'%', {align="r"})
        write_text(cr, 10, 710, conky_parse('${top_mem name 5}'), {})
        write_text(cr, 150, 710, conky_parse('${top_mem mem 5}')..'%', {align="r"})

        write_text(cr, 10, 740, "Batterie: ", {})
        write_text(cr, 150, 740, conky_parse('${battery BAT0}'), {align="r"})
        write_text(cr, 10, 754, "Restzeit: ", {})
        write_text(cr, 150, 754, conky_parse('${battery_time BAT0}'), {align="r"})
--        write_text(cr, 150, 736, conky_parse('${battery_short BAT0}')..'%', {align="r"})
        write_text(cr, 76, 130, os.date("%H")..':'..os.date("%M"), {align="c", color="0x1e90ff", size=42, bold=true})

-- Lines (Linien)

        cairo_rectangle(cr,10, 10, 135, 3)
        cairo_set_source_rgba(cr,rgb_to_rgba(0xffffff,1.0))
        cairo_fill(cr)
        cairo_rectangle(cr,10, 810, 140, 3)
        cairo_set_source_rgba(cr,rgb_to_rgba(0xffffff,1.0))
        cairo_fill(cr)
        cairo_rectangle(cr,10, 563, 140, 2)
        cairo_set_source_rgba(cr,rgb_to_rgba(0xffffff,1.0))
        cairo_rectangle(cr,10, 718, 140, 2)
        cairo_set_source_rgba(cr,rgb_to_rgba(0xffffff,1.0))
        cairo_rectangle(cr,10, 772, 140, 2)
        cairo_set_source_rgba(cr,rgb_to_rgba(0xffffff,1.0))
        cairo_fill(cr)
	end

   cairo_surface_destroy(cs)
   cairo_destroy(cr)
end
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Conky Showoff thread 2024

Post by Logansfury »

I just saw it myself:

that "xxxxxxxxxxxxxxx" is supposed to be a custom Key that I get from openweathermap.org correct?
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Conky Showoff thread 2024

Post by Logansfury »

Logansfury wrote: Sun Feb 04, 2024 2:02 am I just saw it myself:

that "xxxxxxxxxxxxxxx" is supposed to be a custom Key that I get from openweathermap.org correct?
As luck would have it, I registered for an API key years ago for a Tasker weather Task on my android phone. I referenced the text doc of my api keys and replaced xxxxxxxxxxx with my key in the .sh file, but still nothing is displaying when I start this widget in CM2.
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Conky Showoff thread 2024

Post by Bleys »

Logansfury wrote: Sun Feb 04, 2024 2:02 am I just saw it myself:

that "xxxxxxxxxxxxxxx" is supposed to be a custom Key that I get from openweathermap.org correct?
yes.. I would only use the weather LUA script until that is running and then add the rest: https://gist.github.com/rdschmidt/3e903 ... 5e313ea9b7

Unfortunately I have not yet added an English description.

do not forget to make the sh script executable
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Conky Showoff thread 2024

Post by Bleys »

Test individual components for troubleshooting. E.g. the SH script in the terminal:

Code: Select all

ralf@Nexus:~$ '/home/ralf/.conky/wetter.sh' 
Bedeckt,9.7,5.1,96,04n,08:06,17:25,07:24,1023,29.4
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Conky Showoff thread 2024

Post by Logansfury »

Bleys wrote: Sun Feb 04, 2024 2:26 am Test individual components for troubleshooting. E.g. the SH script in the terminal:

Code: Select all

ralf@Nexus:~$ '/home/ralf/.conky/wetter.sh' 
Bedeckt,9.7,5.1,96,04n,08:06,17:25,07:24,1023,29.4
I got

Code: Select all

logansfury@OptiPlex-5040:~/.conky$ ./wetter.sh
Klarer Himmel,8.4,18,64,01n,06:40,17:08,22:30,1014,0
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Conky Showoff thread 2024

Post by Bleys »

Logansfury wrote: Sun Feb 04, 2024 2:30 am
I got

Code: Select all

logansfury@OptiPlex-5040:~/.conky$ ./wetter.sh
Klarer Himmel,8.4,18,64,01n,06:40,17:08,22:30,1014,0
I think you want the weather conditions in english and not metric values:
wetter=$(curl -s 'api.openweathermap.org/data/2.5/weather?lat='$lat'&lon='$lon'&lang=de&units=metric&appid='$key 2>/dev/null)
wetter=$(curl -s 'api.openweathermap.org/data/2.5/weather?lat='$lat'&lon='$lon'&appid='$key 2>/dev/null)
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Conky Showoff thread 2024

Post by Logansfury »

Bleys wrote: Sun Feb 04, 2024 2:38 am I think you want the weather conditions in english and not metric values:
wetter=$(curl -s 'api.openweathermap.org/data/2.5/weather?lat='$lat'&lon='$lon'&lang=de&units=metric&appid='$key 2>/dev/null)
wetter=$(curl -s 'api.openweathermap.org/data/2.5/weather?lat='$lat'&lon='$lon'&appid='$key 2>/dev/null)
looking good:

Code: Select all

logansfury@OptiPlex-5040:~/.conky$ ./wetter.sh
clear sky,280.2,9,65,01n,06:40,17:09,22:40,1014,0
logansfury@OptiPlex-5040:~/.conky$ 
I have the wetter.sh in my .conky dir but I see only the background when I try to run the conkyrc
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Conky Showoff thread 2024

Post by Logansfury »

do these reference dependencies I don't have?

Code: Select all

require 'cairo'
require "imlib2"
require "math"
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Conky Showoff thread 2024

Post by Bleys »

Start conky in Terminal...
Screen Capture_select-area_20240204074834.jpg
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
Post Reply

Return to “Compiz, Conky, Docks & Widgets”