local cairo_loaded, cairo = pcall(require, "cairo") if not cairo_loaded then cairo = require("lualib.cairo") end function draw_eq_bar(cr, x, y, percent, segments) local seg_height = 4 local seg_width = 30 local gap = 2 local lit_segments = math.ceil((percent / 100) * segments) for i = 1, segments do if i > (segments - 2) then cairo_set_source_rgba(cr, 1.0, 0.2, 0.2, i <= lit_segments and 1.0 or 0.15) else cairo_set_source_rgba(cr, 0.2, 1.0, 0.2, i <= lit_segments and 1.0 or 0.15) end local seg_y = y - (i * (seg_height + gap)) cairo_rectangle(cr, x, seg_y, seg_width, seg_height) cairo_fill(cr) end 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) if cs == nil then return end local cr = cairo_create(cs) if cr == nil then cairo_surface_destroy(cs) return end -- Fehlerfreie Temperatur-Zuweisung ohne verschachtelte Anführungszeichen local temp_val = tonumber(conky_parse('${hwmon 0 temp 1}')) or tonumber(conky_parse('${hwmon 1 temp 1}')) or 40 local values = { tonumber(conky_parse('${cpu cpu1}')) or 0, tonumber(conky_parse('${cpu cpu2}')) or 0, tonumber(conky_parse('${memperc}')) or 0, tonumber(conky_parse('${swapperc}')) or 0, tonumber(conky_parse('${fs_used_perc /home}')) or 0, tonumber(conky_parse('${fs_free_perc /}')) or 0, math.min(100, (tonumber(conky_parse('${downspeedf}')) or 0) * 10), math.min(100, (tonumber(conky_parse('${upspeedf}')) or 0) * 10), tonumber(conky_parse('${wireless_link_qual_perc}')) or 0, 0, math.min(100, temp_val * 1.2) } -- Balken-Basis (Y-Achse nach unten verschoben, um Platz für den Knopf zu machen) local start_x = 40 local base_y = 260 local spacing = 85 for i, val in ipairs(values) do draw_eq_bar(cr, start_x + (i-1) * spacing, base_y, val, 8) end -- Großer Drehregler (Sichtbar und zentriert über den Balken) local cpu_total = tonumber(conky_parse('${cpu cpu0}')) or 0 local center_x = 512 local center_y = 110 local radius = 45 local pat = cairo_pattern_create_radial(center_x-10, center_y-10, 5, center_x, center_y, radius) cairo_pattern_add_color_stop_rgb(pat, 0, 0.9, 0.85, 0.8) cairo_pattern_add_color_stop_rgb(pat, 1, 0.5, 0.45, 0.4) cairo_set_source(cr, pat) cairo_arc(cr, center_x, center_y, radius, 0, 2 * math.pi) cairo_fill(cr) cairo_pattern_destroy(pat) local angle = 135 + (cpu_total / 100) * 270 local rad_angle = angle * math.pi / 180 local line_x = center_x + (radius - 10) * math.cos(rad_angle) local line_y = center_y + (radius - 10) * math.sin(rad_angle) cairo_set_source_rgb(cr, 0.7, 0.2, 0.2) cairo_set_line_width(cr, 3) cairo_move_to(cr, center_x + (radius - 25) * math.cos(rad_angle), center_y + (radius - 25) * math.sin(rad_angle)) cairo_line_to(cr, line_x, line_y) cairo_stroke(cr) cairo_set_source_rgb(cr, 1, 1, 1) cairo_select_font_face(cr, "DejaVu Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD) cairo_set_font_size(cr, 11) cairo_move_to(cr, center_x - radius - 25, center_y + radius) cairo_show_text(cr, "MIN") cairo_move_to(cr, center_x + radius, center_y + radius) cairo_show_text(cr, "MAX") cairo_destroy(cr) cairo_surface_destroy(cs) end