You are not logged in.

#2821 Today 02:37:02

Sector11
Mod Squid Tpyo Knig
From: Upstairs
Registered: 2015-08-20
Posts: 8,532

Re: Show us your conky

From the Screenshot thread:

hhh wrote:

Nice, a cross between the very old monitors and The Matrix.

Always good to have a link to Nerd Fonts, I still haven't one I like better than Monofur. Hurmit (misspelled on the page, it's Hermit when installed IIRC) is my second choice.

https://www.nerdfonts.com/font-downloads

I use to use monofur a LOT but I'm leaning more to Fira Code and Fira Mono for readability these days.  IMHO, much cleaner for coding (conkys anyway)
802503307_261109-232056.webp

Hermit looks nice though.


Beardog Linux, hosted by SoxDog
(Debian 13 - X11)
Still a Conky 1.9er at heart.

Offline

#2822 Today 10:57:13

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 3,171

Re: Show us your conky

^^Thanks, my friend!  smile

------------------------
This is about this Conky by @easysid from 2018:
802709696_easy.jpg

It worked with AccuWeather.
I tinkered with it for weeks without success. In the end, I did have a window, but it was empty. Yesterday, out of frustration, I asked the AI built into FF-esr.  wink
And it worked.

Here's the requested command sequence:
###when I tested the data source I'd been using so far with AccuWeather, it showed “No Permission” (I had suspected as much, but just didn't know how to implement it)

curl -L --max-time 30 -A "Mozilla/5.0" "https://www.accuweather.com/en/de/lichtenstein/09350/current-weather/171261" | head -c 1000
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   442  100   442    0     0   6135      0 --:--:-- --:--:-- --:--:--  6225
<HTML><HEAD>
<TITLE>Access Denied</TITLE>
</HEAD><BODY>
<H1>Access Denied</H1>
 
You don't have permission to access "http&#58;&#47;&#47;www&#46;accuweather&#46;com&#47;en&#47;de&#47;lichtenstein&#47;09350&#47;current&#45;weather&#47;171261" on this server.<P>
Reference&#32;&#35;18&#46;c9e61702&#46;1794303674&#46;548e1f8
<P>https&#58;&#47;&#47;errors&#46;edgesuite&#46;net&#47;18&#46;c9e61702&#46;1794303674&#46;548e1f8</P>
</BODY>
</HTML>

###testing the new one with Open-Meteo (the AI suggested doing this with Open-Meteo to preserve the Conky layout)

curl -s "https://api.open-meteo.com/v1/forecast?latitude=50.756&longitude=12.630&current=temperature_2m,weather_code&timezone=Europe%2FBerlin"
{"latitude":50.74872,"longitude":12.642987,"generationtime_ms":0.0286102294921875,"utc_offset_seconds":3600,"timezone":"Europe/Berlin","timezone_abbreviation":"GMT+1","elevation":310.0,"current_units":{"time":"iso8601","interval":"seconds","temperature_2m":"°C","weather_code":"wmo code"},"current":{"time":"2026-11-10T10:30","interval":900,"temperature_2m":4.3,"weather_code":53}}

###testing the Existing Icons

ls /media/DATEN/Abgleich/Conky/derivantArt/easysid/duo/icons/
11.png  15.png  19.png  22.png  29.png  33.png  37.png  40.png  44.png  7.png    i14.png  i25.png  i40.png  i5.png
12.png  16.png  1.png   23.png  2.png   34.png  38.png  41.png  4.png   8.png    i15.png  i2.png   i42.png  i9.png
13.png  17.png  20.png  25.png  30.png  35.png  39.png  42.png  5.png   i12.png  i17.png  i35.png  i44.png  ina.png
14.png  18.png  21.png  26.png  32.png  36.png  3.png   43.png  6.png   i13.png  i24.png  i3.png   i4.png

###Backup

cp duo.lua duo.lua.backup
cp helpers.lua helpers.lua.backup

###Check the “new” LUA for errors caused by old entries (which should no longer appear)

grep -n "get_accuweather\|weather_url" /media/DATEN/Abgleich/Conky/derivantArt/easysid/duo/duo.lua
15:--weather_url = "https://www.accuweather.com/en/de/lichtenstein/09350/current-weather/171261"
16:--weather_url = "https://www.accuweather.com/en/in/delhi/202396/current-weather/202396"

###Final Review of the New LUA

grep -n "get_openmeteo\|conditions\|local temp" /media/DATEN/Abgleich/Conky/derivantArt/easysid/duo/duo.lua
64:conditions = {
83:        local result = get_openmeteo()
86:            conditions = result
91:    local temp = tostring(conditions.temp or "--").."°"
92:    local icon     = conditions.icon

The result: 802720859_bildschirmfoto_2026-11-10_10-17-57.png

Offline

#2823 Today 11:06:16

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 3,171

Re: Show us your conky

The modified code:
conky.conf

conky.config = {
    -- Conky settings
    background = false,
    update_interval = 1,
    cpu_avg_samples = 2,
    net_avg_samples = 2,
    override_utf8_locale = true,
    double_buffer = true,
    no_buffers = true,
    short_units = true,
    text_buffer_size = 2048,
    imlib_cache_size = 0,
    use_xft = true,
    font = 'sans:size=10',
    xftalpha = 1,
    own_window_type = 'normal',--desktop',
    own_window_hints = 'undecorated,skip_taskbar,skip_pager,below',  --sticky,
    own_window = true,
    own_window_transparent = true,
    own_window_argb_visual = true,
    -- own_window_colour = '303030',
    default_color = '5dacba',
    border_inner_margin = 0,
    border_outer_margin = 0,

    minimum_width = 450,
    minimum_height = 450,
    alignment = 'middle_middle',
    gap_x = 5,
    gap_y = 5,

    -- Graphics settings
    draw_shades = false,
    draw_outline = false,
    draw_borders = false,
    draw_graph_borders = false,

    -- Lua load
    lua_load = 'duo.lua',
    lua_draw_hook_pre = 'main',
};

conky.text = [[

]];

duo.lua

--[[
duo.lua
easysid, Sunday, 21 January 2018 20:05 IST

Credits:
* mrpeachy for put_text()
* rainmeter skin - http://fav.me/db7o7rr
* weather icons  - http://fav.me/dbgs998

Changes:
* Sunday, 21 January 2018 19:51 IST
    - Initial commit
]]

--weather_url = "https://www.accuweather.com/en/de/lichtenstein/09350/current-weather/171261"
--weather_url = "https://www.accuweather.com/en/in/delhi/202396/current-weather/202396"


weather_update_time = 600

T = {
    -- drawing
    xc = 250,
    yc = 250,
    radius = 180,
    base_color = {0x3a434c, 1},
    top_fill = {0x16a1a4, 1},
    bottom_fill = {0x434d57, 1},
    hours_ring = 10, -- thickness
    minutes_ring = 6, --thickness
    hours_color = {0x757575, 1},
    minutes_color = {0xf48282, 1},
    -- texts --
    text_color = {0xf0f0f0, 1},
    font = 'raleway',
    -- temperature
    temp_x = 250,
    temp_y = 170,
    temp_fs = 50,
    -- time
    time_x = 250,
    time_y = 370,
    time_fs = 50,
    time_format = "%H:%M",
    -- icon
    icon_w = 100,
    icon_h = 100,

} -- end settings_t


-- ********** You should not need to change anything below this **********


local scriptpath = debug.getinfo(1,'S').source:match("@(.*/).*.lua") or './'
package.path = string.format("%s;%s?.lua", package.path, scriptpath)

require 'cairo'
require 'cairo_xlib'
require 'imlib2'
require 'helpers'

local first_run = 1
conditions = {
    temp = "--",
    icon = "1",
    cond = "Wetterdaten werden geladen",
    location = "Lichtenstein"
}

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)
    cr = cairo_create(cs)
    local updates = tonumber(conky_parse('${updates}'))
    local counter = updates % weather_update_time
    -- drawing code here
    if counter == 0 or first_run then
        first_run = nil

        local result = get_openmeteo()

        if result then
            conditions = result
        end
    end

    -- basic setup
    local temp = tostring(conditions.temp or "--").."°"
    local icon     = conditions.icon
    local iconfile = string.format("%sicons/%s.png", scriptpath, icon)
    local r        = T.radius - T.hours_ring
    local h_r      = r + T.hours_ring/2
    local m_r      = r - T.minutes_ring/2
    local time     = os.date(T.time_format)
    -- draw the widgets
    draw_circle({x=T.xc, y=T.yc, r=T.radius, fill_color=T.base_color})
    draw_circle({x=T.xc, y=T.yc, r=r, start=-math.pi, ends=0,
                    fill_color=T.top_fill})
    draw_circle({x=T.xc, y=T.yc, r=r, start=0, ends=math.pi,
                    fill_color=T.bottom_fill})
    draw_clock({arg='%H', max=24, x=T.xc, y=T.yc, r=h_r,
                    border_width=T.hours_ring, border_color=T.hours_color})
    draw_clock({arg='%M', max=60, x=T.xc, y=T.yc, r=m_r,
                    border_width=T.minutes_ring, border_color=T.minutes_color})
    put_text({x=T.time_x, y=T.time_y, f=T.font, fs=T.time_fs, txt=time,
                color=T.text_color, hj='c'})
    put_text({x=T.temp_x, y=T.temp_y, f=T.font, fs=T.temp_fs, txt=temp,
                color=T.text_color, hj='c'})
    put_image({x=T.xc, y=T.yc, file=iconfile, w=T.icon_w, h=T.icon_h, hj='c', vj='m'})
    cairo_destroy(cr)
    cairo_surface_destroy(cs)
    cr=nil
end -- function main

function draw_clock(t)
    local value = tonumber(os.date(t.arg))
    local theta = scale(value, 0, t.max, 0, 2*math.pi) - math.pi/2
    draw_circle({x=t.x, y=t.y, r=t.r, start=-math.pi/2, ends=theta,
                border_width=t.border_width, border_color=t.border_color})
end --function draw_clock

function show_text(t)
    -- just a wrapper around put_text
    local value = nil
    if t.arg then value = os.date(t.arg) else value = t.label end
    put_text({x=t.x, y=t.y, f=t.font, fs=t.fs, c=t.color,
                hj=t.align, txt=string.upper(value)})
end -- function show_text

--[[function deadbeef_nowplaying()
    -- a better approach is to use a dbus loop that writes to /tmp file
    local command = "deadbeef --nowplaying-tf '%artist%^%title%' 2> /dev/null"
    local f = io.popen(command)
    local data = f:read("*a")
    f:close()
    local t = {}
    t.artist, t.title = data:match("([^^]+)^([^^]+)")
    return t
end -- function deadbeef_nowplaying
]]

Offline

#2824 Today 11:12:40

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 3,171

Re: Show us your conky

Why isn't this code being integrated into the forum software?
Line 245 in the lua script is only executed by the forum software with ' '   Without it, it won't display the entire code.
helpers.lua

    local result = weather['code'] or { "1", "Unbekannt" }

New attempt with " "
The terminal isn't showing me any errors, so pay attention to line 245. If any of you try this, please let me know if you're familiar with Lua. Thanks!  wink

--[[
helpers.lua
helper functions for conky configs
easysid
* Monday, 22 January 2018 20:36 IST
    - added put_image()
* Friday, 12 January 2018 15:21 IST
    - Initial commit

Functions
* put_text({x, y, c, f, fs, face, txt, hj, vj})
* put_image({x, y, file, w, h})
* get_text_extents(txt, f, fs, face)
* get_accuweather(url)
* normalize(value, min, max)
* scale(value, a, b, x, y) -- map a value from [a, b] to [x, y]
* draw_circle({x, y, r, start, ends, border, border_color, fill_color})
* rgba_to_r_g_b_a({color, alpha})
]]


function get_text_extents(txt, f, fs, face)
    -- text, font, font size, weight/slant
    local extents = cairo_text_extents_t:create()
    tolua.takeownership(extents)
    if face == "normal" then
        face = {f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL}
    elseif face == "bold" then
        face = {f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD}
    elseif face == "italic" then
        face = {f, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_NORMAL}
    elseif face == "bolditalic" then
        face = {f, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD}
    else
        face = {f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL}
        print('face not set - "normal", "bold", "italic", "bolditalic"')
        print('falling back to using "normal"')
    end
    cairo_select_font_face(cr, face[1], face[2], face[3])
    cairo_set_font_size(cr, fs)
    cairo_text_extents(cr, txt, extents)
    return extents
end -- function text_extents

function put_text(txj)
    --Taken from mrpeachy's wun.lua
    --args: c, a, f, fs, face, x, y, txt, hj, vj

    local function justify(jtxt, x, hj, y, vj, f, face, fs)
        local extents= get_text_extents(jtxt, f, fs, face)
        if face == "normal" then
            face = {f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL}
        elseif face == "bold" then
            face = {f, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD}
        elseif face == "italic" then
            face = {f, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_NORMAL}
        elseif face == "bolditalic" then
            face = {f, CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD}
        else
            print('face not set - "normal", "bold", "italic", "bolditalic"')
        end
        local wx = extents.x_advance
        local wd = extents.width
        local hy = extents.height
        local bx = extents.x_bearing
        local by = extents.y_bearing+hy
        local tx = x
        local ty = y
        -- set horizontal alignment - left, centre, right
        if hj == "l" then
            x = x-bx
        elseif hj == "c" then
            x = x-((wx-bx)/2)-bx
        elseif hj == "r" then
            x = x-wx
        else
            print("hj not set correctly - l, c, r")
        end
        -- vertical - normal, normal-ybearing, middle, middle-ybearing, top
        if vj == "n" then
            y = y
        elseif vj == "nb" then
            y = y-by
        elseif vj == "m" then
            y = y+((hy-by)/2)
        elseif vj == "mb" then
            y = y+(hy/2)-by
        elseif vj == "t" then
            y = y+hy-by
        else
            print("vj not set correctly - n, nb, m, mb, t")
        end
        return face, fs, x, y, tx, ty
    end -- function justify

    -- set variables
    local  c    = txj.c     or  {0xffffff, 1}
    local  f    = txj.f     or  "monospace"
    local  fs   = txj.fs    or  12
    local  x    = txj.x     or  10
    local  y    = txj.y     or  10
    local  txt  = txj.txt   or  "text not set"
    local  hj   = txj.hj    or  "l"
    local  vj   = txj.vj    or  "n"
    local  face = txj.face  or  "normal"
    -- print text
    local face, fs, x, y = justify(txt, x, hj, y, vj, f, face, fs)
    cairo_select_font_face(cr, face[1], face[2], face[3])
    cairo_set_font_size(cr, fs)
    cairo_move_to(cr, x, y)
    cairo_set_source_rgba(cr, rgba_to_r_g_b_a(c))
    cairo_show_text(cr, txt)
    cairo_stroke(cr)
end --function put_text

function put_image(t)
    local image = imlib_load_image(t.file)
    if image == nil then
        print("Unable to load image", t.file)
        return
    end
    imlib_context_set_image(image)
    local img_w  = imlib_image_get_width()
    local img_h  = imlib_image_get_height()
    local x      = t.x or  100
    local y      = t.y or  100
    local w      = t.w or  img_w
    local h      = t.h or  img_h
    local hj     = t.hj or 'l'
    local vj     = t.vj or 'b'
    if hj == 'c' then
        x = x - w/2
    elseif hj == 'r' then
        x = x - w
    end
    if vj == 'm' then
        y = y - h/2
    elseif vj == 't' then
        y = y - h
    end
    local scaled = imlib_create_cropped_scaled_image(0, 0, img_w, img_h, w, h)
    imlib_free_image()
    imlib_context_set_image(scaled)
    imlib_render_image_on_drawable(x, y)
    imlib_free_image()
    image = nil
end

--[[function get_accuweather(url)
    -- use the current weather url
    url = string.gsub(url, "weather%-forecast", "current-weather")
    local agent = "User-Agent:Mozilla/5.0 Chrome/57.0.2987.133 Safari/537.36"
    local f = io.popen(
                string.format("curl --max-time 60 -H '%s' '%s'", agent, url)
                )
    local data = f:read("*a")
    f:close()
    local location = string.match(data, '<div class="display-name">(.-)</div>')
    local current  = string.match(data, 'cu: {.-}')
    local temp     = tonumber(string.match(current, "rf : '(.-)'"))
    local icon     = string.match(current, "wx : '(.-)'")
    local cond     = string.match(current, "txt : '(.-)'")
    return {temp=temp, icon=icon, cond=cond, location=location}
end -- function get_accuweather
]]

function get_openmeteo()
    local url = "https://api.open-meteo.com/v1/forecast?latitude=50.756&longitude=12.630&current=temperature_2m,weather_code&timezone=Europe%2FBerlin"

    local f = io.popen(
        "curl -fsSL --max-time 30 '" .. url .. "'"
    )

    if not f then
        return {
            temp = "--",
            icon = "1",
            cond = "Verbindungsfehler",
            location = "Lichtenstein"
        }
    end

    local data = f:read("*a")
    f:close()

    if not data or data == "" then
        return {
            temp = "--",
            icon = "1",
            cond = "Keine Wetterdaten",
            location = "Lichtenstein"
        }
    end

    local current = string.match(data, '"current"%s*:%s*{(.-)}')

    if not current then
        return {
            temp = "--",
            icon = "1",
            cond = "Wetterdaten fehlen",
            location = "Lichtenstein"
        }
    end

    local temp = tonumber(
        string.match(current, '"temperature_2m"%s*:%s*([%-%.%d]+)')
    )

    local code = tonumber(
        string.match(current, '"weather_code"%s*:%s*(%d+)')
    )

    local weather = {
        [0] = { "1", "Klarer Himmel" },
        [1] = { "2", "Überwiegend klar" },
        [2] = { "3", "Teilweise bewölkt" },
        [3] = { "7", "Bewölkt" },
        [45] = { "11", "Nebel" },
        [48] = { "11", "Nebel" },
        [51] = { "12", "Nieselregen" },
        [53] = { "12", "Nieselregen" },
        [55] = { "12", "Nieselregen" },
        [56] = { "12", "Gefrierender Nieselregen" },
        [57] = { "12", "Gefrierender Nieselregen" },
        [61] = { "18", "Regen" },
        [63] = { "18", "Regen" },
        [65] = { "18", "Starker Regen" },
        [66] = { "18", "Gefrierender Regen" },
        [67] = { "18", "Gefrierender Regen" },
        [71] = { "22", "Schneefall" },
        [73] = { "22", "Schneefall" },
        [75] = { "22", "Starker Schneefall" },
        [77] = { "22", "Schneegriesel" },
        [80] = { "26", "Regenschauer" },
        [81] = { "26", "Regenschauer" },
        [82] = { "26", "Starke Regenschauer" },
        [85] = { "29", "Schneeschauer" },
        [86] = { "29", "Starke Schneeschauer" },
        [95] = { "38", "Gewitter" },
        [96] = { "38", "Gewitter mit Hagel" },
        [99] = { "38", "Starkes Gewitter" }
    }

    local result = weather["code"] or { "1", "Unbekannt" }

    return {
        temp = temp or "--",
        icon = result[1],
        cond = result[2],
        location = "Lichtenstein"
    }
end

function normalize(value, min ,max)
    -- normalize a value to [min, max]
    return (value - min)/(max - min)
end --function normalize

function scale(value, a, b, x, y)
    -- map a value from [a, b] to [x, y]
    return value*(y - x)/(b - a)
end -- function scale

function draw_circle(t)
    -- args - x, y, radius, start angle, end angle,
    --        border width, border_color, fill_color
    -- setup defaults
    local x = t.x or 10
    local y = t.y or 10
    local radius = t.r or 20
    local start = t.start or 0
    local ends = t.ends or 2*math.pi
    local border = t.border_width or 1
    -- end setup
    cairo_set_line_width(cr, border)
    if t.border_color then
        cairo_set_source_rgba(cr, rgba_to_r_g_b_a(t.border_color))
        cairo_arc(cr, x, y, radius, start, ends)
        cairo_stroke(cr)
    end
    if t.fill_color then
        cairo_set_source_rgba(cr, rgba_to_r_g_b_a(t.fill_color))
        cairo_arc(cr, x, y, radius, start, ends)
        cairo_fill(cr)
    end
end -- function draw_circle

function rgba_to_r_g_b_a(tcolor)
    local color, alpha = tcolor[1], tcolor[2]
    return((color / 0x10000) % 0x100) / 255.,
       ((color / 0x100) % 0x100) / 255., (color % 0x100) / 255., alpha
end -- function rgba

Have Fun!  big_smile

Last edited by unklar (Today 13:15:11)

Offline

#2825 Today 16:20:50

marens
Member
From: World without M$
Registered: 2023-02-02
Posts: 1,318

Re: Show us your conky

^ I have already written about the fact that the AccuWeather developers changed the headers.

The truth is that this doesn't work:

curl -L --max-time 30 -A "Mozilla/5.0" "https://www.accuweather.com/en/de/lichtenstein/09350/current-weather/171261"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   442  100   442    0     0   6135      0 --:--:-- --:--:-- --:--:--  6225
<HTML><HEAD>
<TITLE>Access Denied</TITLE>
</HEAD><BODY>
<H1>Access Denied</H1>  ...

But this works:

$ curl  --compressed   -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:147.0) Gecko/20100101 Firefox/147.0'   -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'   -H 'Accept-Language: en-US,en;q=0.9'   -H 'Accept-Encoding: gzip, deflate, br, zstd'   -H 'DNT: 1'   -H 'Sec-GPC: 1'   -H 'Connection: keep-alive'   -H 'Upgrade-Insecure-Requests: 1'   -H 'Sec-Fetch-Dest: document'   -H 'Sec-Fetch-Mode: navigate'   -H 'Sec-Fetch-Site: same-origin'   -H 'Priority: u=0, i'   -H 'TE: trailers'  -o $HOME/curr_cond_raw  "https://www.accuweather.com/en/de/lichtenstein/09350/current-weather/171261"
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 51998    0 51998    0     0  78784      0 --:--:-- --:--:-- --:--:-- 78665

https://forums.bunsenlabs.org/viewtopic … 34#p151734

Just check the file –/curr_cond_raw.


If people would know how little brain is ruling the world, they would die of fear.

Offline

Board footer

Powered by FluxBB