Hello everybody.
Would it be possible to add a parameter allowing the automatic addition of line break when one or more lines of text exceed the container, as with HTML ?
I am not certain, but we might have this before without the config. <= v1.11.4 or so.
For people who do not want to w8t, how to add auto line break in bash :
word1='Cette phrase est longue.'
word2=' Dieser Satz ist lang.'
word3=' This sentence is long.'
echo "${word1}${word2}${word3}" | fmt --width=20
Adapt --width=20 to your line lenght

@lasers
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main(void) {
char str[] = "20 Cette phrase est longue. Dieser Satz ist lang. This sentence is long.";
char *old_ptr = str;
char buf[200];
char *buf_ptr = buf;
char num[50];
char *nums = num;
unsigned int x = 0;
unsigned int z = 1;
for (; *old_ptr; old_ptr++) {
if (!isdigit((unsigned char)*old_ptr)) {
break;
}
*nums++ = *old_ptr;
}
*nums = '\0';
old_ptr++;
x = (unsigned int)strtoul(num, (char **)NULL, 10);
for (; *old_ptr; old_ptr++, z++) {
if (x == z) {
z = 1U;
*buf_ptr++ = '\n';
}
*buf_ptr++ = *old_ptr;
}
*buf_ptr++ = '\0';
printf("%s\n",buf);
return EXIT_SUCCESS;
}
My computer broke and I wrote this code on my tablet. Such code with malloc can be added to conky too.
@lasers
This goes in common.h
void print_fold(struct text_object *, char *, unsigned int);
this goes in common.c
void print_fold(struct text_object *obj, char *p, unsigned int p_max_size) {
char *old_ptr = obj->data.s;
char *buf;
char *buf_ptr = buf;
char num[50];
char *nums = num;
unsigned int x = 0;
unsigned int z = 1;
evaluate(obj->data.s, p, p_max_size);
if (0 != (strcmp(p, ""))) {
old_ptr = p;
}
for (; *old_ptr; old_ptr++) {
if (!isdigit((unsigned char)*old_ptr)) {
break;
}
*nums++ = *old_ptr;
}
*nums = '\0';
if (*old_ptr) {
old_ptr++;
} else {
return;
}
x = (unsigned int)strtoul(num, (char **)NULL, 10);
buf = (char *)malloc(p_max_size * 2);
if (!buf) {
return;
}
for (; *old_ptr; old_ptr++, z++) {
if (x == z) {
z = 1U;
*buf_ptr++ = '\n';
}
*buf_ptr++ = *old_ptr;
}
*buf_ptr++ = '\0';
snprintf(p, p_max_size, "%s", buf);
free(buf);
}
and this goes in core.c
END OBJ(fold, nullptr) obj->data.s = STRNDUP_ARG;
obj->callbacks.print = &print_fold;
obj->callbacks.free = &gen_free_opaque;
Note that I don't have a computer and i leave all the testing up to you.
Test it with static text and one with variables in it.
My computer broke
Huh. More than a year ago...

I lost 75 lbs since 6 months ago. Still want to lose more. I'm a gym rat now. Currently injured tho.
Anyway, welcome back, @su8! We need to get you a computer. :wink:
I am not certain, but we might have this before without the config.
<= v1.11.4or so.
Just ran git bisect. We never had this. I think I recall textwrap behavior in journal (https://github.com/brndnmtthws/conky/issues/565).
Most helpful comment
Just ran git bisect. We never had this. I think I recall textwrap behavior in
journal(https://github.com/brndnmtthws/conky/issues/565).