Conky not starting after Lua 5.4 update - ('.')(",)

I had an issue - after the update - with conky not starting. Not sure if anyone else is having the problem.

Basically it’s because my scripts are OLD.
So I worked out that with conky 1.11.6_pre it generally tries to do this job on the fly, but obviously failed.

So the solution - make a file in your .local/bin called ‘convert.lua’. (This should be in your $PATH - you can check using echo $PATH)

Paste this:

Summary

#! /usr/bin/lua

local usage = [[
Usage: convert.lua old_conkyrc [new_conkyrc]

Tries to convert conkyrc from the old v1.x format to the new, lua-based format.

Keep in mind that there is no guarantee that the output will work correctly
with conky, or that it will be able to convert every conkyrc. However, it
should provide a good starting point.

Although you can use this script with only 1 arg and let it overwrite the old
config, it’s suggested to use 2 args so that the new config is written in a new
file (so that you have backup if something went wrong).

Optional: Install dos2unix. We will attempt to use this if it is available
because Conky configs downloaded from Internet sometimes are created on DOS/Windows
machines with different line endings than Conky configs created on Unix/Linux.

For more information about the new format, read the wiki page
https://github.com/brndnmtthws/conky/wiki
]];

local function quote(s)
if not s:find("[\n’\]") then
return “’” … s … “’”;
end;
local q = ‘’;
while s:find(’]’ … q … ‘]’, 1, true) do
q = q … ‘=’;
end;
return string.format(’[%s[\n%s]%s]’, q, s, q);
end;

local bool_setting = {
background = true, disable_auto_reload = true, double_buffer = true, draw_borders = true,
draw_graph_borders = true, draw_outline = true, draw_shades = true, extra_newline = true,
format_human_readable = true, no_buffers = true, out_to_console = true,
out_to_ncurses = true, out_to_stderr = true, out_to_x = true, override_utf8_locale = true,
own_window = true, own_window_argb_visual = true, own_window_transparent = true,
short_units = true, show_graph_range = true, show_graph_scale = true,
times_in_seconds = true, top_cpu_separate = true, uppercase = true, use_xft = true,
draw_blended = true, forced_redraw = true
};

local num_setting = {
border_inner_margin = true, border_outer_margin = true, border_width = true,
cpu_avg_samples = true, diskio_avg_samples = true, gap_x = true, gap_y = true,
imlib_cache_flush_interval = true, imlib_cache_size = true,
max_port_monitor_connections = true, max_text_width = true, max_user_text = true,
maximum_width = true, mpd_port = true, music_player_interval = true, net_avg_samples = true,
own_window_argb_value = true, pad_percents = true, stippled_borders = true,
text_buffer_size = true, top_name_width = true, total_run_times = true,
update_interval = true, update_interval_on_battery = true, xftalpha = true,
xinerama_head = true,
};

local split_setting = {
default_bar_size = true, default_gauge_size = true, default_graph_size = true,
minimum_size = true
};

local colour_setting = {
color0 = true, color1 = true, color2 = true, color3 = true, color4 = true, color5 = true,
color6 = true, color7 = true, color8 = true, color9 = true, default_color = true,
default_outline_color = true, default_shade_color = true, own_window_colour = true
};

local function alignment_map(value)
local map = { m = ‘middle’, t = ‘top’, b = ‘bottom’, r = ‘right’, l = ‘left’ };
if map[value] == nil then
return value;
else
return map[value];
end;
end;

local function handle(setting, value)
setting = setting:lower();
if setting == ‘’ then
return ‘’;
end;
if split_setting[setting] then
local x, y = value:match(’^(%S+)%s*(%S*)$’);
local ret = setting:gsub(’_size’, ‘_width = ‘) … x … ‘,’;
if y ~= ‘’ then
ret = ret … ’ ’ … setting:gsub(’_size’, ‘height = ') … y … ‘,’;
end;
return ‘\t’ … ret;
end;
if bool_setting[setting] then
value = value:lower();
if value == ‘yes’ or value == ‘true’ or value == ‘1’ or value == ‘’ then
value = ‘true’;
else
value = ‘false’;
end;
elseif not num_setting[setting] then
if setting == ‘alignment’ and value:len() == 2 then
value = alignment_map(value:sub(1,1)) … '
’ … alignment_map(value:sub(2,2));
elseif colour_setting[setting] and value:match(’^[0-9a-fA-F]+$’) then
value = ‘#’ … value;
elseif setting == ‘xftfont’ then
setting = ‘font’;
end;
value = quote(value);
end;
return ‘\t’ … setting … ’ = ’ … value … ‘,’;
end;

local function convert(s)
local setting, comment = s:match(’^([^#])#?(.)\n$’);
if comment ~= ‘’ then
comment = ‘–’ … comment;
end;
comment = comment … ‘\n’;
return handle(setting:match(’^%s*(%S*)%s*(.-)%s*$’)) … comment;
end;

local input;
local output;

if conky == nil then --> standalone program
– 1 arg: arg is input and outputfile
– 2 args: 1st is inputfile, 2nd is outputfile
– 0, 3 or more args: print usage to STDERR and quit
if #arg == 1 or #arg == 2 then
if os.execute(‘command -v dos2unix 2&>1’) then
os.execute('dos2unix ’ … arg[1]);
end
input = io.input(arg[1]);
else
io.stderr:write(usage);
return;
end;
else
– we are called from conky, the filename is the first argument
input = io.open(…, ‘r’);
end;

local config = input:read(’*a’);
input:close();

local settings, text = config:match(’^(.-)TEXT\n(.*)$’);

local converted = ‘conky.config = {\n’ … settings:gsub(’.-\n’, convert) … '};\n\nconky.text = ’ …
quote(text) … ‘;\n’;

if conky == nil then
if #arg == 2 then
output = io.output(arg[2]);
else
output = io.output(arg[1]);
end
output:write(converted);
output:close();
else
return assert(load(converted, ‘converted config’));
end;

Make it executable :wink: Then find your conky folder and simply do this (e.g. for my ‘network.conky’ script)
$ convert.lua network.conky

I’d advise making a backup first - I hadn’t realised it will simply overwrite the contents of the file.

However, it worked.

My new network conky looks like this:
network
Exactly the same, but the file now looks like this:

Summary

conky.config = {

– Conky settings

background = true,
update_interval = 1,
double_buffer = true,
no_buffers = true,
imlib_cache_size = 10,
window = 'specifications',

gap_x = 5,
gap_y = 0,
minimum_width = 20, minimum_height = 0,
maximum_width = 220,
alignment = 'top_right',
own_window = true,
own_window_type = 'normal',
own_window_transparent = false,
own_window_argb_visual = true,
own_window_argb_value = 80,
own_window_hints = 'undecorated,sticky,skip_taskbar,skip_pager',

–own_window_type normal
–own_window_transparent no
–own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
–own_window_argb_visual yes
–own_window_argb_value 0
border_inner_margin = 0,
border_outer_margin = 0,
graphics = ‘settings’,

draw_shades = false,
default_shade_color = '#484848',
draw_outline = false,
default_outline_color = '#dddddd',
draw_borders = false,
draw_graph_borders = false,
default_graph_width = 40, default_graph_height = 80,
show_graph_scale = true,
show_graph_range = false,
text = 'settings',

use_xft = true,
xftalpha = 0,
font = 'Droid Sans:size=9',
text_buffer_size = 256,
override_utf8_locale = true,
useful = 'shortenings',

short_units = true,
pad_percents = 2,
top_name_width = 30,
color = 'scheme',

default_color = '#FFFFFF',
color1 = '#FFFFFF',
color2 = '#2dcba5',-- teal
color3 = '#16a085',-- teal2
color4 = '#FFFFFF',
color5 = '#DCDCDC',

–DCDCDC
color6 = ‘#FFFFFF’,
color7 = ‘#FFFFFF’,
color8 = ‘#A9CFF4’,
–A9CFF4

– iphone wlp0s20u12

};

conky.text = [[
${if_existing /proc/net/route enp2s0} ${upspeedgraph enp2s0 30,50 efa644 ff5b00 3500 -l} ${alignr}${downspeedgraph enp2s0 30,50 88a669 55ff1a 10000 -l}${color }${font mitr:bold:size=2}
${font mitr:bold:size=9}Up: ${upspeed enp2s0} ${alignr}Dn: ${downspeed enp2s0}${endif} ${if_existing /proc/net/route wlp0s20u12}WiFi${upspeedgraph wlp0s20u12 50,125 efa644 ff5b00 3500 -l} ${alignr}${downspeedgraph wlp0s20u12 50,125 88a669 55ff1a 10000 -l}
${color }Up: ${upspeed wlp0s20u12} Σ=${totalup wlp0s20u12}${alignr}Dn: ${color8}${downspeed wlp0s20u12} Σ=${totaldown wlp0s20u12}${endif} ${if_existing /proc/net/route wlp0s20u11} ${upspeedgraph wlp0s20u11 50,125 efa644 ff5b00 3500 -l} ${alignr}${downspeedgraph wlp0s20u11 50,125 88a669 55ff1a 10000 -l}
${color }Up: ${upspeed wlp0s20u11} Σ=${totalup wlp0s20u11}${alignr}Dn: ${color8}${downspeed wlp0s20u11} Σ=${totaldown wlp0s20u11}${endif} ]];

So now to see if it works on my ‘processes’ conky :wink:

2 Likes

Atm my conky lua is broken, wil change picture if it works again :relaxed:

edit: it works
@Ben can you repaste the code from github in the summary between code brackets as I had the same issue as @xR4zz mentioned

The lua script doesn’t work for me. I get the following error:

/usr/bin/lua: ./convert.lua:25: invalid escape sequence near '"[
‘]’

Copy paste this script from here: conky/convert.lua at master · brndnmtthws/conky · GitHub

It will work.

2 Likes

Hi xR4zz, if like me your conky script does not work and you do not know how to modify it you can install lua53 which is in the extra repository;)

It’s so buggy i never bother with conky. Seriously are there any people that managed to run conky without breaking for a full year?

Pasting the linked GitHub script text in an executable convert.lua file worked for my conkyrc files. Thanks a lot. :wink:

After update my conkyrc is broken.

@Ben @xR4zz Actually, you don’t need to create a lua - script. A perfectly working convert - script version is included in conky and can be found in /usr/share/doc/conky*

@hakasham that’s because your config needs to be converted …

2 Likes

Ok, thx but I don’t know how. I’ll look around.

you can do that by using the convert.lua script in the /usr/share/doc/conky* folder on your config (maybe backup it before running the convert)
syntax: ./convert.lua /path/to/your/config/file

1 Like

I just have a conkyrc in /home. Can I use for?

Ok I just needed to give execute permission to the lua script and its worked. Thx for the help.

1 Like

Interesting - that’s the script I copied and pasted to my /.local/bin folder - non destructive way to test and no root permissions required :wink:

1 Like

Yup.

Since 2013, across 4 distros. Although to be fair, I don’t want/need/like all the fancy eye-candy.

2 Likes

Stick this in your ~/.local/bin folder

Worked for both of my ancient scripts:
conkies
Not the clock though - that’s KWIN effect ‘osd clock’.

Configurations · brndnmtthws/conky Wiki · GitHub
Converting old configs to 1.10
The script is not always flawless. You might need to tweak it somewhat if it does not work. Otherwise, the script should already take care of the more annoying and tedious work (i.e. syntax change) for you

so may need to use style guidelines from section 1.10 and later versions to edit conky.conf

save file to ~/.config/conky/conky.conf
Where is conky.conf?

@woistmeinauto would you be possibly be using conky-manager?
that is old and buggy and i would not expect configurations have been updated. not much activity on Launchpad site
Unable to read conky 1.10.x configuration file

1 Like

It worked for me but only for two conkies, the bigger part of my configs files just could’not be converted.
Well, enough for today. :cup_with_straw:
Btw, it works only with Conky (1.11.5), not with Conky-lua-nv, right?! (Or it was my fault again?)

Edit:
It works for more conkies (even four of my collection now!), but (for me only) in the "conky (1.11.5) + its convert.lua " combo. Conky-lua-nv doesn’t work at all.

you can install ‘lua53’ beside ‘lua54’ … I did it so and conky works again like before.

1 Like

Installed lua53 (only forgot to mention it )
Still, convert.lua can’t convert all of them.
Well, never mind, so far so good.

https://aur.archlinux.org/packages/conky-manager2-git/

also possible pamac build conky-manager2-git

2 Likes