diff --git a/doc/variables.xml b/doc/variables.xml index 45b86b57..214a959c 100644 --- a/doc/variables.xml +++ b/doc/variables.xml @@ -656,6 +656,7 @@ Number of the desktop on which conky is running + or the message "Not running in X" if this is the case. @@ -665,6 +666,7 @@ Name of the desktop on which conky is running + or the message "Not running in X" if this is the case. @@ -673,7 +675,8 @@ - Number of desktops + Number of desktops or the message "Not running + in X" if this is the case. @@ -2149,6 +2152,7 @@ Number of the monitor on which conky is running + or the message "Not running in X" if this is the case. @@ -2157,7 +2161,8 @@ - Number of monitors + Number of monitors or the message "Not running + in X" if this is the case. diff --git a/src/common.c b/src/common.c index 10305f56..7d664a1c 100644 --- a/src/common.c +++ b/src/common.c @@ -453,7 +453,7 @@ void update_stuff(void) } #ifdef X11 - if (NEED(INFO_X11)) { + if (NEED(INFO_X11) && x_initialised == YES) { update_x11info(); } #endif diff --git a/src/conky.c b/src/conky.c index ea3f0dd8..687018d3 100644 --- a/src/conky.c +++ b/src/conky.c @@ -4923,22 +4923,41 @@ static void generate_text_internal(char *p, int p_max_size, } } #ifdef X11 +#define NOT_IN_X "Not running in X" OBJ(monitor) { - snprintf(p, p_max_size, "%d", cur->x11.monitor.current); + if(x_initialised != YES) { + strncpy(p, NOT_IN_X, p_max_size); + }else{ + snprintf(p, p_max_size, "%d", cur->x11.monitor.current); + } } OBJ(monitor_number) { - snprintf(p, p_max_size, "%d", cur->x11.monitor.number); + if(x_initialised != YES) { + strncpy(p, NOT_IN_X, p_max_size); + }else{ + snprintf(p, p_max_size, "%d", cur->x11.monitor.number); + } } OBJ(desktop) { - snprintf(p, p_max_size, "%d", cur->x11.desktop.current); + if(x_initialised != YES) { + strncpy(p, NOT_IN_X, p_max_size); + }else{ + snprintf(p, p_max_size, "%d", cur->x11.desktop.current); + } } OBJ(desktop_number) { - snprintf(p, p_max_size, "%d", cur->x11.desktop.number); + if(x_initialised != YES) { + strncpy(p, NOT_IN_X, p_max_size); + }else{ + snprintf(p, p_max_size, "%d", cur->x11.desktop.number); + } } OBJ(desktop_name) { - if(cur->x11.desktop.name != NULL) { - strncpy(p, cur->x11.desktop.name, p_max_size); - } + if(x_initialised != YES) { + strncpy(p, NOT_IN_X, p_max_size); + }else if(cur->x11.desktop.name != NULL) { + strncpy(p, cur->x11.desktop.name, p_max_size); + } } #endif /* X11 */