aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/details.lua
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-18 15:14:06 +0200
committerDanilo M. <danix@danix.xyz>2026-10-18 15:14:06 +0200
commit1ed34aa44879296eef34bb0509e8b96533217f15 (patch)
tree9c0f6e6fbc6afbca26a1dd949cc615610db4bc06 /widgets/details.lua
parent403c76a77ff66dac9f84fa9a49d415a8e2442cee (diff)
downloadconky-theme-udt-1ed34aa44879296eef34bb0509e8b96533217f15.tar.gz
conky-theme-udt-1ed34aa44879296eef34bb0509e8b96533217f15.zip
feat(details): the wind compass takes the big value's place
card.standard() accepts a function as spec.big and calls it with the big slot's right edge, top and size, so a card can put a graphic where the big number goes. details draws its compass there, 1.2x the slot, and the band under the rows is gone: the card drops to 4.25 rows and sky moves up to take the space. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'widgets/details.lua')
-rw-r--r--widgets/details.lua25
1 files changed, 15 insertions, 10 deletions
diff --git a/widgets/details.lua b/widgets/details.lua
index 45f2f3d..36ce016 100644
--- a/widgets/details.lua
+++ b/widgets/details.lua
@@ -1,4 +1,5 @@
--- Details: wind, humidity, UV and air quality, over a wind compass.
+-- Details: wind, humidity, UV and air quality, with a wind compass as the
+-- big value.
--
-- Adapted from the Conky-Mirage theme's details tiles by alexsson-xexpanderx
-- (see lib/weather.lua). UV and AQI are the measured quantities here, so they
@@ -10,17 +11,18 @@ local weather = require 'lib.weather'
local M = {}
-local function draw_compass(cr, x, y, w, h, colors, deg, S)
- local r = math.min(w, h) / 2 - S * 0.1
- if r < 24 then return end
- local cx, cy = x + w / 2, y + h / 2
+-- The compass fills the big value's slot: `size` square, its right edge at
+-- `right`, its top at `top`.
+local function draw_compass(cr, right, top, size, colors, deg)
+ local r = size / 2
+ local cx, cy = right - r, top + r
card.rgba(cr, colors.rule, 0.8)
cairo_set_line_width(cr, 1)
cairo_new_path(cr)
cairo_arc(cr, cx, cy, r, 0, math.pi * 2)
cairo_stroke(cr)
- local size = math.min(r * 0.2, S * 0.32)
+ local size = r * 0.28
card.font(cr, card.FONT_MONO, size, false)
card.rgba(cr, colors.label)
for i, p in ipairs({ 'N', 'E', 'S', 'W' }) do
@@ -32,7 +34,7 @@ local function draw_compass(cr, x, y, w, h, colors, deg, S)
if type(deg) ~= 'number' then return end
-- Open-Meteo gives where the wind comes FROM; the needle points where it goes.
local a = math.rad(deg + 180)
- local tip = r - size * 2
+ local tip = r - size * 1.6
local sa, ca = math.sin(a), math.cos(a)
-- A filled arrowhead at the tip, so the needle reads one way only. The shaft
-- stops at the head's base: a stroke run to the apex would blunt it.
@@ -74,10 +76,13 @@ function M.draw(cr, rect, colors)
colors[weather.uv_role(uv)] },
{ 'AIR (EAQI)', weather.num(aqi), colors[weather.aqi_role(aqi)] },
}
- local y, S = card.standard(cr, inner, colors, {
- icon = card.ICON.details, title = 'DETAILS', rows = rows, share = 0.8,
+ card.standard(cr, inner, colors, {
+ icon = card.ICON.details, title = 'DETAILS', rows = rows,
+ big = function(cr, right, top, size)
+ -- 1.2x the slot: the first row starts lower than the big text ends.
+ draw_compass(cr, right, top, size * 1.2, colors, c.wind_deg)
+ end,
})
- draw_compass(cr, inner.x, y, inner.w, inner.y + inner.h - y, colors, c.wind_deg, S)
end
return M