brndnmtthws / conky

Light-weight system monitor for X, Wayland (sort of), and other things, too
https://conky.cc
GNU General Public License v3.0
7.27k stars 620 forks source link

[Bug]: conky 1.21. does not start consistently #1939

Closed zlice closed 2 months ago

zlice commented 5 months ago

What happened?

Putting conky in my fluxbox(fork, shynebox) startup file has worked fine for years. But with 1.21 my distro update to the other day it is very finicky if it will start at all. Starting manually in a terminal will start conky with some delay and then run fine until reboot/re-login.

1.19.6 started every time, so I went back to that.

Version

1.21.1

Which OS/distro are you seeing the problem on?

Linux (other)

Conky config

conky.config = {
-- double_buffer = true,
-- ^prevents weird glitching, missing, double text
use_xft = true,
font = 'RobotoMono:size=10',
default_color = '000000',
maximum_width = 70,
minimum_width = 70,
background = true,
own_window = true,
own_window_colour = 'ff9C3B',
minimum_height = 200,
own_window_transparent = false,
-- xorg
own_window_type = 'override',
-- wayland
-- own_window_hints = 'undecorated,below',
-- own_window_type = 'normal',
alignment = 'tr',
gap_x = 0,
gap_y = 0,
draw_shades = false,
draw_outline = false,
draw_borders = false,
draw_graph_borders = false,
cpu_avg_samples = 3,
net_avg_samples = 2,
}

conky.text = [[
${hwmon k10temp temp 3}° ${hwmon amdgpu temp 2}°
mem ${memperc}%
${offset 10}${mem}
${voffset -5}${if_match ${cpu cpu0} < 100} ${endif}${if_match ${cpu cpu0} < 10}0${endif}${cpu cpu0}%${voffset 10}${offset -31}${cpugraph cpu0 20,70 d8d8d8 d8d8d8}
${voffset -5}${if_match ${cpu cpu1} < 100} ${endif}${if_match ${cpu cpu1} < 10}0${endif}${cpu cpu1}%${voffset 10}${offset -40} ${cpugraph cpu1 20,70 d8d8d8 d8d8d8}
${voffset -5}${if_match ${cpu cpu2} < 100} ${endif}${if_match ${cpu cpu2} < 10}0${endif}${cpu cpu2}%${voffset 10}${offset -40} ${cpugraph cpu2 20,70 d8d8d8 d8d8d8}
${voffset -5}${if_match ${cpu cpu3} < 100} ${endif}${if_match ${cpu cpu3} < 10}0${endif}${cpu cpu3}%${voffset 10}${offset -40} ${cpugraph cpu3 20,70 d8d8d8 d8d8d8}
${voffset -5}${if_match ${cpu cpu4} < 100} ${endif}${if_match ${cpu cpu4} < 10}0${endif}${cpu cpu4}%${voffset 10}${offset -40} ${cpugraph cpu4 20,70 d8d8d8 d8d8d8}
${voffset -5}${if_match ${cpu cpu5} < 100} ${endif}${if_match ${cpu cpu5} < 10}0${endif}${cpu cpu5}%${voffset 10}${offset -40} ${cpugraph cpu5 20,70 d8d8d8 d8d8d8}
${voffset 0}${offset 0}eth
${voffset -5}${downspeedgraph myt 20,70 d8d8d8 d8d8d8}
${voffset -10}${offset 0}${offset 0}${voffset 15}${downspeedf myt}k

]]


config notes: amdgpu is not currently in use. Not sure if that would affect things

### Stack trace

_No response_

### Relevant log output

_No response_
Caellian commented 4 months ago

Can you run conky with conky -DD and provide some logs? ps -e shows it's not running?

zlice commented 3 months ago

with debug it looks like it's failing on XrmSetDatabase(display, db);

the comment mentions copying from dunst, which has an updated comment about XrmSetDatabase docs being inaccurate ? https://github.com/dunst-project/dunst/blob/master/src/x11/x.c#L499

tried double checking prop.value and a couple things but it's still failing randomly when starting with wm.

sometimes XGetTextProperty fails and skips all the xrdb destroy/set logic. other times things work and the XrmSetDatabase runs fine? seen elsewhere about XGetTextProperty defaulting to ~/.Xdefaults if there's no xrdb, but not sure if that's related in any way

zlice commented 3 months ago

l - o - l

i think this works? not entirely sure if it's right, just going with the dunst logic

https://stackoverflow.com/questions/37908716/x11-xlibint-h-naming-conflict-issues-are-they-supposed-to-be-named-min-max

--- a/src/x11.cc
+++ b/src/x11.cc
@@ -33,6 +33,9 @@
 #include "x11.h"

 #include <X11/X.h>
+#include <X11/Xlibint.h>
+#undef min
+#undef max
 #include <sys/types.h>

 #include "common.h"
@@ -314,6 +317,8 @@
       XrmDestroyDatabase(db);
     }

+    // https://github.com/dunst-project/dunst/blob/master/src/x11/x.c#L499
+    display->db = NULL; // should be new or deleted
     db = XrmGetStringDatabase((const char *)prop.value);
     XrmSetDatabase(display, db);
   }
zlice commented 3 months ago

this has been solid for me for a bit now. should i make a PR or is the patch with the hacky 'undef's enough?

MisterCcobD commented 2 months ago

Still does not start for me

:~$ conky -DD
DEBUG(0) [./src/conky.cc:2603]: reading contents from config file '/etc/conky/conky.conf'
conky: Unknown setting 'default_outline_color'
conky: Unknown setting 'gap_x'
conky: Unknown setting 'border_width'
conky: Unknown setting 'show_graph_scale'
conky: Unknown setting 'use_xft'
conky: Unknown setting 'own_window'
conky: Unknown setting 'draw_outline'
conky: Unknown setting 'draw_shades'
conky: Unknown setting 'out_to_x'
conky: Unknown setting 'minimum_width'
conky: Unknown setting 'draw_borders'
conky: Unknown setting 'alignment'
conky: Unknown setting 'default_shade_color'
conky: Unknown setting 'minimum_height'
conky: Unknown setting 'default_color'
conky: Unknown setting 'stippled_borders'
conky: Unknown setting 'show_graph_range'
conky: Unknown setting 'own_window_type'
conky: Unknown setting 'gap_y'
conky: Unknown setting 'double_buffer'
conky: Unknown setting 'draw_graph_borders'
conky: Unknown setting 'own_window_class'
conky: Unknown setting 'font'
DEBUG(1) [./src/core.cc:2059]: no templates to replace
DEBUG(1) [./src/core.cc:2059]: no templates to replace
conky: unknown variable '$hr'
DEBUG(1) [./src/core.cc:689]: Adding $cpu for CPU 0
DEBUG(1) [./src/core.cc:703]: Adding $cpubar for CPU 0
conky: unknown variable '$hr'
conky: unknown variable '$hr'
Caellian commented 2 months ago

@zlice undefs are perfectly fine if definitions leaked from X11 headers cause issues with conky code (like it would be the case for min and max). But it looks like it's enough to only add:

display->db = nullptr;

I'm guessing min and max are defined in <X11/Xlibint.h> which you don't seem to use in changed code.

In any case, a PR would be very welcomed. Thank you for the effort debugging this.

zlice commented 2 months ago

When I don't have the header I get an incomplete type error. Maybe that's a void-linux/compiler thing?

I'll make a PR in the morning. Thanks

/usr/bin/g++ -D_LARGEFILE64_SOURCE -D_POSIX_C_SOURCE=200809L -I/builddir/conky-1.21.4/3rdparty/toluapp/include -I/builddir/conky-1.21.4/build -I/usr/include/freetype2 -I/usr/include/lua5.3 -I/usr/include/libxml2 -I/builddir/conky-1.21.4/3rdparty/Vc -I/builddir/conky-1.21.4/build/src -I/builddir/conky-1.21.4/build/data -DNDEBUG -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2    -ffile-prefix-map=/builddir/conky-1.21.4/build=. -std=c++17 -Werror -MD -MT src/CMakeFiles/conky_core.dir/x11.cc.o -MF src/CMakeFiles/conky_core.dir/x11.cc.o.d -o src/CMakeFiles/conky_core.dir/x11.cc.o -c /builddir/conky-1.21.4/src/x11.cc
/builddir/conky-1.21.4/src/x11.cc: In function 'void update_x11_resource_db(bool)':
/builddir/conky-1.21.4/src/x11.cc:317:12: error: invalid use of incomplete type 'Display'
  317 |     display->db = NULL; // should be new or deleted
      |            ^~
In file included from /builddir/conky-1.21.4/src/x11.h:37,
                 from /builddir/conky-1.21.4/src/x11.cc:33:
/usr/include/X11/Xlib.h:251:8: note: forward declaration of 'Display'
  251 | struct _XDisplay;               /* Forward declare before use for C++ */
      |        ^~~~~~~~~