我想给我的数字钟的字体在康奇,外边,这是一种不同的颜色。不过,我不知道该怎么做。这张照片是我想要做的事情的一个例子。

发布于 2023-05-27 20:34:20
不能和Conky一个人一起做。需要使用Cairo图形库进行一些Lua编程。以下内容主要基于https://www.cairographics.org/samples/上的"text“Cairo示例代码片段,并添加了明显必要的内容。
Lua文件(我将其命名为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}
]]结果时钟显示

https://unix.stackexchange.com/questions/746490
复制相似问题