conky
conky copied to clipboard
Unicode blocks for console_bar
I would love to use Unicode block elements with the console_bar_fill
, console_bar_unfill
, and console_graph_ticks
configuration variables. This would allow me to make good looking conky statuslines. However, the bars produced by conky do not show the correct glyphs. The strange part is the glyphs do display properly outside of bars and graphs.
A sample configuration file:
conky.config = {
background = false,
font = 'DejaVu Sans Mono:size=12',
out_to_console = true,
out_to_ncurses = false,
out_to_stderr = false,
out_to_x = false,
use_xft = true,
console_bar_fill = '█',
console_bar_unfill = '░',
console_graph_ticks = ' ,▁,▂,▃,▄,▅,▆,▇,█',
}
conky.text = [[
${membar}
console_bar_fill = '█',
console_bar_unfill = '░',
console_graph_ticks = ' ,▁,▂,▃,▄,▅,▆,▇,█',
]]
And the output
�����
console_bar_fill = '█',
console_bar_unfill = '░',
console_graph_ticks = ' ,▁,▂,▃,▄,▅,▆,▇,█',
Am I missing something here?
I'm having a similar issue. Poking around in the source code, I believe this may be due to the progress bar functions in C being written with 8-bit chars in mind. I'm not familiar enough with conky's code to say this definitively however. In the meantime, I think a temporary solution may be to set your console_bar and console_graph characters to readable ASCII characters, and then write a custom Lua script that will parse your bars and graphs in conky.text and replace the ASCII placeholders with the desired unicode characters. However, I would also appreciate if these new conky.config options were capable of accepting and parsing unicode characters.
EDIT Here is my loose functionality for unicode characters in the progress bar. This is neither pretty nor efficient, but it works. Here's my setup:
--conky.conf
conky.config = {
lua_load = "~/.config/conky/scripts/conky_lua_scripts.lua",
console_bar_fill=':',
console_bar_unfill=' ',
update_interval=.5,
out_to_x=false,
out_to_console=true,
};
conky.text = [[CPU ${lua to_unicode : █ ${cpubar 1, 20}} ${cpu cpu0}% || mem ${lua to_unicode : █ ${membar 1, 10}} $memperc% || ${time %H:%M %Y-%m-%d}]]
--~/.config/conky/scripts/conky_lua_scripts.lua
function conky_to_unicode(ascii, uni, str)
output = string.gsub(conky_parse(str), ascii, uni)
return output
end
As you can see, I have the custom to_unicode function which takes the original ASCII value, then replaces its instances with the desired unicode character, and then returns the string. The annoying part is that I haven't figured out how to pass Lua variables into conky.text, so instead of setting an ascii and a unicode variable at the top of the page, it has to be done manually with my iteration. I'm sure this could be improved on very easily, but it works for now. To work better with console_graph_ticks, you'd likely need to rewrite the function to take an arbitrary list of ascii/unicode pairs, but given that I have never touched Lua before today I think I'll leave it as is :). I'd still love to see this functionality built in though!
What would it take to have unicode support in conky? Replace char
by wchar_t
everywhere? Use std::wstring
instead of char* buffer
? Is the code using C-style allocations because of Lua? How can we help?
I would also like to see this bug fixed (or this feature added?).
This issue is stale because it has been open 365 days with no activity. Remove stale label or comment, or this issue will be closed in 30 days.