conky 中的时钟字体

conky 中的时钟字体

我想给我的数字时钟字体 conky 一个不同颜色的外边缘。但我不知道该怎么做。该图片是我想做的事情的一个例子。

在此输入图像描述

答案1

光靠康基是做不到的。需要使用 Cairo 图形库进行一些 Lua 编程。以下是重重地基于“文本”开罗示例代码片段https://www.cairgraphics.org/samples/添加了明显必要的东西。

卢阿文件(我命名cairoclock.lua并保存在~/bin/lua_scripts):

require 'cairo'

function conky_cairotext()

    if conky_window == nil then return end

    t=os.date("%I:%M:%S%p")     -- Get Time (see Lua Ref Manual for info)

    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)     -- Create a Drawing Context
   
    cairo_select_font_face (cr, "Serif", CAIRO_FONT_SLANT_NORMAL,
                               CAIRO_FONT_WEIGHT_NORMAL);
    cairo_set_font_size (cr, 60.0);
    cairo_move_to (cr, 70.0, 165.0);
    cairo_text_path (cr, t);
    cairo_set_source_rgb (cr, 1, 0.95, 0);      -- Set Text Color
    cairo_fill_preserve (cr);
    cairo_set_source_rgb (cr, .24, .24, 1);     -- Set Text Edge Color
    cairo_set_line_width (cr, 2.60);            -- Set Text Edge Width
    cairo_stroke (cr);

    return ""   -- Not needed, but prevents constant warnings
                -- when called from conky run in a terminal.
end

最小 Conky 文件供测试用:

conky.config = {
    lua_load = '~/bin/lua_scripts/cairoclock.lua',
    alignment = 'top_left',
    use_xft = true,
    override_utf8_locale = true,
    gap_x = 0,
    gap_y = 0,
    minimum_width = 455,
    minimum_height = 280,
    own_window = true,
    own_window_hints = 'below',
    own_window_type = 'desktop',
    own_window_argb_visual=true,
    own_window_transparent = false,
    own_window_colour = 'white',
    double_buffer = true,
    update_interval = 1,
}

conky.text = [[
    ${lua cairotext}
]]

结果时钟显示

结果时钟显示

相关内容