1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-13 19:22:58 +00:00

out_to_x can now be turned off

This commit is contained in:
Nikolas Garofil 2009-02-14 13:03:11 +01:00
parent 227e5a3d38
commit 1085d2b27e
7 changed files with 666 additions and 508 deletions

View File

@ -1,8 +1,11 @@
2009-02-15
* Added out_to_x
2009-02-12 2009-02-12
* Added overwrite_file and append_file * Added overwrite_file and append_file
2009-02-10 2009-02-10
* Added output_to_stderr * Added out_to_stderr
2009-02-08 2009-02-08
* Refactor top code, add top_time to sort by process cpu time (thanks * Refactor top code, add top_time to sort by process cpu time (thanks

View File

@ -323,6 +323,16 @@
<para></para></listitem> <para></para></listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><command><option>out_to_x</option></command>
</term>
<listitem>
When set to no, there will be no output in X (useful when you also use things like out_to_console).
If you set it to no, make sure that it's placed before all other X-related setting (take the first
line of your configfile to be sure). Default value is yes
<para></para></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><command><option>overwrite_file</option></command> <term><command><option>overwrite_file</option></command>
</term> </term>

View File

@ -326,6 +326,12 @@ Print text to stdout.
\fB\*(T<\fBout_to_stderr\fR\*(T>\fR \fB\*(T<\fBout_to_stderr\fR\*(T>\fR
Print text to stderr. Print text to stderr.
.TP
\fB\*(T<\fBout_to_x\fR\*(T>\fR
When set to no, there will be no output in X (useful when you also use things like out_to_console).
If you set it to no, make sure that it's placed before all other X-related setting (take the first
line of your configfile to be sure). Default value is yes
.TP .TP
\fB\*(T<\fBappend_file\fR\*(T>\fR \fB\*(T<\fBappend_file\fR\*(T>\fR
Append the file given as argument. Append the file given as argument.

View File

@ -4,6 +4,9 @@
# of keeping the documentation more maintainable. # of keeping the documentation more maintainable.
# Check http://conky.sf.net for an up-to-date-list. # Check http://conky.sf.net for an up-to-date-list.
#set to no if you don't want to see anything in X
out_to_x yes
# set to yes if you want Conky to be forked in the background # set to yes if you want Conky to be forked in the background
background no background no

View File

@ -5,7 +5,7 @@
syntax "conky" "(\.*conkyrc.*$|conky.conf)" syntax "conky" "(\.*conkyrc.*$|conky.conf)"
## Configuration items ## Configuration items
color green "\<(alignment|background|show_graph_range|show_graph_scale|border_margin|border_width|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|default_color|default_shade_color|default_shadecolor|default_outline_color|default_outlinecolor|imap|pop3|mpd_host|mpd_port|mpd_password|music_player_interval|sensor_device|cpu_avg_samples|net_avg_samples|double_buffer|override_utf8_locale|draw_borders|draw_graph_borders|draw_shades|draw_outline|out_to_console|out_to_stderr|overwrite_file|append_file|use_spacer|use_xft|font|xftalpha|xftfont|use_xft|gap_x|gap_y|mail_spool|minimum_size|maximum_width|no_buffers|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|top_cpu_separate|short_units|pad_percents|own_window|own_window_class|own_window_title|own_window_transparent|own_window_colour|own_window_hints|own_window_type|stippled_borders|temp1|temp2|update_interval|total_run_times|uppercase|max_specials|max_user_text|text_buffer_size|max_port_monitor_connections)\>" color green "\<(alignment|background|show_graph_range|show_graph_scale|border_margin|border_width|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|default_color|default_shade_color|default_shadecolor|default_outline_color|default_outlinecolor|imap|pop3|mpd_host|mpd_port|mpd_password|music_player_interval|sensor_device|cpu_avg_samples|net_avg_samples|double_buffer|override_utf8_locale|draw_borders|draw_graph_borders|draw_shades|draw_outline|out_to_console|out_to_stderr|out_to_x|overwrite_file|append_file|use_spacer|use_xft|font|xftalpha|xftfont|use_xft|gap_x|gap_y|mail_spool|minimum_size|maximum_width|no_buffers|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|top_cpu_separate|short_units|pad_percents|own_window|own_window_class|own_window_title|own_window_transparent|own_window_colour|own_window_hints|own_window_type|stippled_borders|temp1|temp2|update_interval|total_run_times|uppercase|max_specials|max_user_text|text_buffer_size|max_port_monitor_connections)\>"
## Configuration item constants ## Configuration item constants
color yellow "\<(above|below|bottom_left|bottom_right|bottom_middle|desktop|dock|no|none|normal|override|skip_pager|skip_taskbar|sticky|top_left|top_right|top_middle|middle_left|middle_right|undecorated|yes)\>" color yellow "\<(above|below|bottom_left|bottom_right|bottom_middle|desktop|dock|no|none|normal|override|skip_pager|skip_taskbar|sticky|top_left|top_right|top_middle|middle_left|middle_right|undecorated|yes)\>"

View File

@ -51,6 +51,7 @@ syn keyword ConkyrcSetting
\ draw_outline \ draw_outline
\ out_to_console \ out_to_console
\ out_to_stderr \ out_to_stderr
\ out_to_x
\ overwrite_file \ overwrite_file
\ append_file \ append_file
\ use_spacer \ use_spacer

View File

@ -132,6 +132,11 @@ int top_cpu, top_mem, top_time;
#define OVERWRITE_FILE 8 #define OVERWRITE_FILE 8
#define APPEND_FILE 16 #define APPEND_FILE 16
static int output_methods; static int output_methods;
enum {
NO = 0,
YES = 1,
NEVER = 2
} x_initialised = NO;
static volatile int g_signal_pending; static volatile int g_signal_pending;
/* Update interval */ /* Update interval */
static double update_interval; static double update_interval;
@ -277,6 +282,7 @@ static void set_font(void);
int addfont(const char *data_in) int addfont(const char *data_in)
{ {
if ( (output_methods & TO_X) == 0 ) return 0;
if (font_count > MAX_FONTS) { if (font_count > MAX_FONTS) {
CRIT_ERR("you don't need that many fonts, sorry."); CRIT_ERR("you don't need that many fonts, sorry.");
} }
@ -310,6 +316,7 @@ int addfont(const char *data_in)
void set_first_font(const char *data_in) void set_first_font(const char *data_in)
{ {
if ( (output_methods & TO_X) == 0 ) return;
if (font_count < 0) { if (font_count < 0) {
if ((fonts = (struct font_list *) malloc(sizeof(struct font_list))) if ((fonts = (struct font_list *) malloc(sizeof(struct font_list)))
== NULL) { == NULL) {
@ -330,6 +337,7 @@ void free_fonts(void)
{ {
int i; int i;
if ( (output_methods & TO_X) == 0 ) return;
for (i = 0; i <= font_count; i++) { for (i = 0; i <= font_count; i++) {
#ifdef XFT #ifdef XFT
if (use_xft) { if (use_xft) {
@ -352,6 +360,7 @@ static void load_fonts(void)
{ {
int i; int i;
if ( (output_methods & TO_X) == 0 ) return;
for (i = 0; i <= font_count; i++) { for (i = 0; i <= font_count; i++) {
#ifdef XFT #ifdef XFT
/* load Xft font */ /* load Xft font */
@ -555,6 +564,7 @@ int check_contains(char *f, char *s)
#ifdef X11 #ifdef X11
static inline int calc_text_width(const char *s, int l) static inline int calc_text_width(const char *s, int l)
{ {
if ( (output_methods & TO_X) == 0 ) return 0;
#ifdef XFT #ifdef XFT
if (use_xft) { if (use_xft) {
XGlyphInfo gi; XGlyphInfo gi;
@ -769,6 +779,7 @@ static char *scan_font(const char *args)
#ifdef X11 #ifdef X11
static void new_font(char *buf, char *args) static void new_font(char *buf, char *args)
{ {
if ( (output_methods & TO_X) == 0 ) return;
if (args) { if (args) {
struct special_t *s = new_special(buf, FONT); struct special_t *s = new_special(buf, FONT);
@ -1934,7 +1945,9 @@ static struct text_object *construct_text_object(const char *s,
#endif #endif
END OBJ(color, 0) END OBJ(color, 0)
#ifdef X11 #ifdef X11
if ( output_methods & TO_X ) {
obj->data.l = arg ? get_x11_color(arg) : default_fg_color; obj->data.l = arg ? get_x11_color(arg) : default_fg_color;
}
#endif /* X11 */ #endif /* X11 */
END OBJ(color0, 0) END OBJ(color0, 0)
obj->data.l = color0; obj->data.l = color0;
@ -5581,6 +5594,7 @@ static void generate_text(void)
#ifdef X11 #ifdef X11
static void set_font(void) static void set_font(void)
{ {
if ( (output_methods & TO_X) == 0 ) return;
#ifdef XFT #ifdef XFT
if (use_xft) { if (use_xft) {
if (window.xftdraw != NULL) { if (window.xftdraw != NULL) {
@ -5600,15 +5614,21 @@ static void set_font(void)
static inline int get_string_width(const char *s) static inline int get_string_width(const char *s)
{ {
#ifdef X11 #ifdef X11
if ( output_methods & TO_X ) {
return *s ? calc_text_width(s, strlen(s)) : 0; return *s ? calc_text_width(s, strlen(s)) : 0;
#else }
return strlen(s);
#endif /* X11 */ #endif /* X11 */
return strlen(s);
} }
static inline int get_string_width_special(char *s) static inline int get_string_width_special(char *s)
{ {
#ifdef X11 #ifdef X11
if ( (output_methods & TO_X) == 0 ) {
#endif
return (s) ? strlen(s) : 0;
#ifdef X11
}
char *p, *final; char *p, *final;
int idx = 1; int idx = 1;
int width = 0; int width = 0;
@ -5642,8 +5662,6 @@ static inline int get_string_width_special(char *s)
} }
free(final); free(final);
return width; return width;
#else
return (s) ? strlen(s) : 0;
#endif /* X11 */ #endif /* X11 */
} }
@ -5653,6 +5671,7 @@ static void text_size_updater(char *s);
int last_font_height; int last_font_height;
static void update_text_area(void) static void update_text_area(void)
{ {
if ( (output_methods & TO_X) == 0 ) return;
int x, y; int x, y;
/* update text size if it isn't fixed */ /* update text size if it isn't fixed */
@ -5761,9 +5780,9 @@ static int draw_mode; /* FG, BG or OUTLINE */
#ifdef X11 #ifdef X11
static long current_color; static long current_color;
#ifdef X11
static void text_size_updater(char *s) static void text_size_updater(char *s)
{ {
if ( (output_methods & TO_X) == 0 ) return;
int w = 0; int w = 0;
char *p; char *p;
@ -5823,10 +5842,10 @@ static void text_size_updater(char *s)
text_height += last_font_height; text_height += last_font_height;
last_font_height = font_height(); last_font_height = font_height();
} }
#endif /* X11 */
static inline void set_foreground_color(long c) static inline void set_foreground_color(long c)
{ {
if ( (output_methods & TO_X) == 0 ) return;
current_color = c; current_color = c;
XSetForeground(display, window.gc, c); XSetForeground(display, window.gc, c);
} }
@ -5864,7 +5883,9 @@ static void draw_string(const char *s)
added = 0; added = 0;
#ifdef X11 #ifdef X11
if ( output_methods & TO_X ) {
max = ((text_width - width_of_s) / get_string_width(" ")); max = ((text_width - width_of_s) / get_string_width(" "));
}
#endif /* X11 */ #endif /* X11 */
/* This code looks for tabs in the text and coverts them to spaces. /* This code looks for tabs in the text and coverts them to spaces.
* The trick is getting the correct number of spaces, and not going * The trick is getting the correct number of spaces, and not going
@ -5885,6 +5906,7 @@ static void draw_string(const char *s)
} }
} }
#ifdef X11 #ifdef X11
if ( output_methods & TO_X ) {
if (text_width == maximum_width) { if (text_width == maximum_width) {
/* this means the text is probably pushing the limit, /* this means the text is probably pushing the limit,
* so we'll chop it */ * so we'll chop it */
@ -5893,9 +5915,11 @@ static void draw_string(const char *s)
tmpstring2[strlen(tmpstring2) - 1] = '\0'; tmpstring2[strlen(tmpstring2) - 1] = '\0';
} }
} }
}
#endif /* X11 */ #endif /* X11 */
s = tmpstring2; s = tmpstring2;
#ifdef X11 #ifdef X11
if ( output_methods & TO_X ) {
#ifdef XFT #ifdef XFT
if (use_xft) { if (use_xft) {
XColor c; XColor c;
@ -5923,6 +5947,7 @@ static void draw_string(const char *s)
strlen(s)); strlen(s));
} }
cur_x += width_of_s; cur_x += width_of_s;
}
#endif /* X11 */ #endif /* X11 */
memcpy(tmpstring1, s, text_buffer_size); memcpy(tmpstring1, s, text_buffer_size);
} }
@ -5933,9 +5958,13 @@ void set_up_gradient(void)
{ {
int i; int i;
#ifdef X11 #ifdef X11
if ( output_methods & TO_X ) {
colour_depth = DisplayPlanes(display, screen); colour_depth = DisplayPlanes(display, screen);
#else }else{
#endif /* X11 */
colour_depth = 16; colour_depth = 16;
#ifdef X11
}
#endif /* X11 */ #endif /* X11 */
if (colour_depth != 24 && colour_depth != 16) { if (colour_depth != 24 && colour_depth != 16) {
ERR("using non-standard colour depth, gradients may look like a " ERR("using non-standard colour depth, gradients may look like a "
@ -6055,6 +6084,10 @@ unsigned long gradient_max(unsigned long first_colour,
static void draw_line(char *s) static void draw_line(char *s)
{ {
if ( (output_methods & TO_X) == 0 ) {
draw_string(s);
return;
}
#ifdef X11 #ifdef X11
char *p; char *p;
int cur_y_add = 0; int cur_y_add = 0;
@ -6389,10 +6422,6 @@ static void draw_line(char *s)
p++; p++;
} }
#else
draw_string(s);
#endif
#ifdef X11
if (cur_y_add > 0) { if (cur_y_add > 0) {
cur_y += cur_y_add; cur_y += cur_y_add;
cur_y -= font_descent(); cur_y -= font_descent();
@ -6407,6 +6436,7 @@ static void draw_line(char *s)
static void draw_text(void) static void draw_text(void)
{ {
#ifdef X11 #ifdef X11
if ( output_methods & TO_X ) {
cur_y = text_start_y; cur_y = text_start_y;
/* draw borders */ /* draw borders */
@ -6431,6 +6461,7 @@ static void draw_text(void)
/* draw text */ /* draw text */
special_index = 0; special_index = 0;
}
#endif /* X11 */ #endif /* X11 */
for_each_line(text_buffer, draw_line); for_each_line(text_buffer, draw_line);
} }
@ -6446,6 +6477,7 @@ static void draw_stuff(void)
if(append_fpointer == NULL) ERR("Can't append '%s' anymore", append_file); if(append_fpointer == NULL) ERR("Can't append '%s' anymore", append_file);
} }
#ifdef X11 #ifdef X11
if ( output_methods & TO_X ) {
selected_font = 0; selected_font = 0;
if (draw_shades && !draw_outline) { if (draw_shades && !draw_outline) {
text_start_x++; text_start_x++;
@ -6478,10 +6510,12 @@ static void draw_stuff(void)
} }
set_foreground_color(default_fg_color); set_foreground_color(default_fg_color);
}
#endif /* X11 */ #endif /* X11 */
draw_mode = FG; draw_mode = FG;
draw_text(); draw_text();
#ifdef X11 #ifdef X11
if ( output_methods & TO_X ) {
#ifdef HAVE_XDBE #ifdef HAVE_XDBE
if (use_xdbe) { if (use_xdbe) {
XdbeSwapInfo swap; XdbeSwapInfo swap;
@ -6491,6 +6525,7 @@ static void draw_stuff(void)
XdbeSwapBuffers(display, &swap, 1); XdbeSwapBuffers(display, &swap, 1);
} }
#endif #endif
}
#endif /* X11 */ #endif /* X11 */
if(overwrite_fpointer != NULL) fclose(overwrite_fpointer); if(overwrite_fpointer != NULL) fclose(overwrite_fpointer);
if(append_fpointer != NULL) fclose(append_fpointer); if(append_fpointer != NULL) fclose(append_fpointer);
@ -6522,7 +6557,7 @@ static void update_text(void)
{ {
generate_text(); generate_text();
#ifdef X11 #ifdef X11
clear_text(1); if ( output_methods & TO_X ) clear_text(1);
#endif /* X11 */ #endif /* X11 */
need_to_update = 1; need_to_update = 1;
} }
@ -6534,13 +6569,15 @@ static void main_loop(void)
#endif #endif
double t; double t;
#ifdef X11 #ifdef X11
Region region = XCreateRegion(); Region region;
#ifdef HAVE_XDAMAGE #ifdef HAVE_XDAMAGE
Damage damage; Damage damage;
XserverRegion region2, part; XserverRegion region2, part;
int event_base, error_base; int event_base, error_base;
#endif
if ( output_methods & TO_X ) {
region = XCreateRegion();
#ifdef HAVE_XDAMAGE
if (!XDamageQueryExtension(display, &event_base, &error_base)) { if (!XDamageQueryExtension(display, &event_base, &error_base)) {
ERR("Xdamage extension unavailable"); ERR("Xdamage extension unavailable");
} }
@ -6548,6 +6585,7 @@ static void main_loop(void)
region2 = XFixesCreateRegionFromWindow(display, window.window, 0); region2 = XFixesCreateRegionFromWindow(display, window.window, 0);
part = XFixesCreateRegionFromWindow(display, window.window, 0); part = XFixesCreateRegionFromWindow(display, window.window, 0);
#endif /* HAVE_XDAMAGE */ #endif /* HAVE_XDAMAGE */
}
#endif /* X11 */ #endif /* X11 */
#ifdef SIGNAL_BLOCKING #ifdef SIGNAL_BLOCKING
@ -6570,6 +6608,7 @@ static void main_loop(void)
#endif #endif
#ifdef X11 #ifdef X11
if ( output_methods & TO_X ) {
XFlush(display); XFlush(display);
/* wait for X event or timeout */ /* wait for X event or timeout */
@ -6599,12 +6638,7 @@ static void main_loop(void)
} else { } else {
/* timeout */ /* timeout */
if (s == 0) { if (s == 0) {
#else
t = (next_update_time - get_time()) * 1000000;
usleep((useconds_t)t);
#endif /* X11 */
update_text(); update_text();
#ifdef X11
} }
} }
} }
@ -6808,12 +6842,18 @@ static void main_loop(void)
XftDrawSetClip(window.xftdraw, region); XftDrawSetClip(window.xftdraw, region);
} }
#endif #endif
#endif /* X11 */
draw_stuff(); draw_stuff();
#ifdef X11
XDestroyRegion(region); XDestroyRegion(region);
region = XCreateRegion(); region = XCreateRegion();
} }
}else{
#endif /* X11 */
t = (next_update_time - get_time()) * 1000000;
if(t > 0) usleep((useconds_t)t);
update_text();
draw_stuff();
#ifdef X11
}
#endif /* X11 */ #endif /* X11 */
#ifdef SIGNAL_BLOCKING #ifdef SIGNAL_BLOCKING
@ -6834,6 +6874,7 @@ static void main_loop(void)
ERR("received SIGINT or SIGTERM to terminate. bye!"); ERR("received SIGINT or SIGTERM to terminate. bye!");
clean_up(); clean_up();
#ifdef X11 #ifdef X11
if ( output_methods & TO_X ) {
XDestroyRegion(region); XDestroyRegion(region);
region = NULL; region = NULL;
#ifdef HAVE_XDAMAGE #ifdef HAVE_XDAMAGE
@ -6841,6 +6882,7 @@ static void main_loop(void)
XFixesDestroyRegion(display, region2); XFixesDestroyRegion(display, region2);
XFixesDestroyRegion(display, part); XFixesDestroyRegion(display, part);
#endif /* HAVE_XDAMAGE */ #endif /* HAVE_XDAMAGE */
}
#endif /* X11 */ #endif /* X11 */
if(overwrite_file != NULL) free(overwrite_file); if(overwrite_file != NULL) free(overwrite_file);
if(append_file != NULL) free(append_file); if(append_file != NULL) free(append_file);
@ -6861,11 +6903,13 @@ static void main_loop(void)
} }
#if defined(X11) && defined(HAVE_XDAMAGE) #if defined(X11) && defined(HAVE_XDAMAGE)
if ( output_methods & TO_X ) {
XDamageDestroy(display, damage); XDamageDestroy(display, damage);
XFixesDestroyRegion(display, region2); XFixesDestroyRegion(display, region2);
XFixesDestroyRegion(display, part); XFixesDestroyRegion(display, part);
XDestroyRegion(region); XDestroyRegion(region);
region = NULL; region = NULL;
}
#endif /* X11 && HAVE_XDAMAGE */ #endif /* X11 && HAVE_XDAMAGE */
} }
@ -6941,6 +6985,7 @@ static void clean_up(void)
info.cpu_usage = NULL; info.cpu_usage = NULL;
} }
#ifdef X11 #ifdef X11
if ( output_methods & TO_X ) {
#ifdef HAVE_XDBE #ifdef HAVE_XDBE
if (use_xdbe) { if (use_xdbe) {
XdbeDeallocateBackBufferName(display, window.back_buffer); XdbeDeallocateBackBufferName(display, window.back_buffer);
@ -6961,6 +7006,7 @@ static void clean_up(void)
XFreeGC(display, window.gc); XFreeGC(display, window.gc);
free_fonts(); free_fonts();
}
#endif /* X11 */ #endif /* X11 */
free_text_objects(&global_root_object); free_text_objects(&global_root_object);
@ -7063,6 +7109,25 @@ static enum alignment string_to_alignment(const char *s)
} }
#endif /* X11 */ #endif /* X11 */
#ifdef X11
static void set_default_configurations_for_x(void)
{
default_fg_color = WhitePixel(display, screen);
default_bg_color = BlackPixel(display, screen);
default_out_color = BlackPixel(display, screen);
color0 = default_fg_color;
color1 = default_fg_color;
color2 = default_fg_color;
color3 = default_fg_color;
color4 = default_fg_color;
color5 = default_fg_color;
color6 = default_fg_color;
color7 = default_fg_color;
color8 = default_fg_color;
color9 = default_fg_color;
}
#endif /* X11 */
static void set_default_configurations(void) static void set_default_configurations(void)
{ {
fork_to_background = 0; fork_to_background = 0;
@ -7098,19 +7163,6 @@ static void set_default_configurations(void)
#ifdef X11 #ifdef X11
show_graph_scale = 0; show_graph_scale = 0;
show_graph_range = 0; show_graph_range = 0;
default_fg_color = WhitePixel(display, screen);
default_bg_color = BlackPixel(display, screen);
default_out_color = BlackPixel(display, screen);
color0 = default_fg_color;
color1 = default_fg_color;
color2 = default_fg_color;
color3 = default_fg_color;
color4 = default_fg_color;
color5 = default_fg_color;
color6 = default_fg_color;
color7 = default_fg_color;
color8 = default_fg_color;
color9 = default_fg_color;
template[0] = strdup(""); template[0] = strdup("");
template[1] = strdup(""); template[1] = strdup("");
template[2] = strdup(""); template[2] = strdup("");
@ -7187,6 +7239,13 @@ static _Bool append_works(const char *path)
return 1; return 1;
} }
static void X11_initialisation() {
output_methods |= TO_X;
init_X11();
set_default_configurations_for_x();
x_initialised = YES;
}
static void load_config_file(const char *f) static void load_config_file(const char *f)
{ {
#define CONF_ERR ERR("%s: %d: config file error", f, line) #define CONF_ERR ERR("%s: %d: config file error", f, line)
@ -7267,7 +7326,17 @@ static void load_config_file(const char *f)
|| strcasecmp(name, b) == 0) || strcasecmp(name, b) == 0)
#ifdef X11 #ifdef X11
CONF2("alignment") { CONF2("out_to_x") {
if(x_initialised == NO) { //don't listen if X is already initialised or if we already know we don't want it
if ( string_to_bool(value) ) {
X11_initialisation();
}else {
if(output_methods & TO_X) output_methods -= TO_X;
x_initialised = NEVER;
}
}
}
CONF("alignment") {
if (window.type == TYPE_DOCK) if (window.type == TYPE_DOCK)
; ;
else if (value) { else if (value) {
@ -7312,75 +7381,105 @@ static void load_config_file(const char *f)
} }
} }
CONF("color0") { CONF("color0") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
color0 = get_x11_color(value); color0 = get_x11_color(value);
} else { } else {
CONF_ERR; CONF_ERR;
} }
} }
}
CONF("color1") { CONF("color1") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
color1 = get_x11_color(value); color1 = get_x11_color(value);
} else { } else {
CONF_ERR; CONF_ERR;
} }
} }
}
CONF("color2") { CONF("color2") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
color2 = get_x11_color(value); color2 = get_x11_color(value);
} else { } else {
CONF_ERR; CONF_ERR;
} }
} }
}
CONF("color3") { CONF("color3") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
color3 = get_x11_color(value); color3 = get_x11_color(value);
} else { } else {
CONF_ERR; CONF_ERR;
} }
} }
}
CONF("color4") { CONF("color4") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
color4 = get_x11_color(value); color4 = get_x11_color(value);
} else { } else {
CONF_ERR; CONF_ERR;
} }
} }
}
CONF("color5") { CONF("color5") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
color5 = get_x11_color(value); color5 = get_x11_color(value);
} else { } else {
CONF_ERR; CONF_ERR;
} }
} }
}
CONF("color6") { CONF("color6") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
color6 = get_x11_color(value); color6 = get_x11_color(value);
} else { } else {
CONF_ERR; CONF_ERR;
} }
} }
}
CONF("color7") { CONF("color7") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
color7 = get_x11_color(value); color7 = get_x11_color(value);
} else { } else {
CONF_ERR; CONF_ERR;
} }
} }
}
CONF("color8") { CONF("color8") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
color8 = get_x11_color(value); color8 = get_x11_color(value);
} else { } else {
CONF_ERR; CONF_ERR;
} }
} }
}
CONF("color9") { CONF("color9") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
color9 = get_x11_color(value); color9 = get_x11_color(value);
} else { } else {
CONF_ERR; CONF_ERR;
} }
} }
}
#define TEMPLATE_CONF(n) \ #define TEMPLATE_CONF(n) \
CONF("template"#n) { \ CONF("template"#n) { \
if (value) { \ if (value) { \
@ -7401,26 +7500,35 @@ static void load_config_file(const char *f)
TEMPLATE_CONF(8) TEMPLATE_CONF(8)
TEMPLATE_CONF(9) TEMPLATE_CONF(9)
CONF("default_color") { CONF("default_color") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
default_fg_color = get_x11_color(value); default_fg_color = get_x11_color(value);
} else { } else {
CONF_ERR; CONF_ERR;
} }
} }
}
CONF3("default_shade_color", "default_shadecolor") { CONF3("default_shade_color", "default_shadecolor") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
default_bg_color = get_x11_color(value); default_bg_color = get_x11_color(value);
} else { } else {
CONF_ERR; CONF_ERR;
} }
} }
}
CONF3("default_outline_color", "default_outlinecolor") { CONF3("default_outline_color", "default_outlinecolor") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
default_out_color = get_x11_color(value); default_out_color = get_x11_color(value);
} else { } else {
CONF_ERR; CONF_ERR;
} }
} }
}
#endif /* X11 */ #endif /* X11 */
CONF("imap") { CONF("imap") {
if (value) { if (value) {
@ -7572,20 +7680,27 @@ static void load_config_file(const char *f)
use_xft = string_to_bool(value); use_xft = string_to_bool(value);
} }
CONF("font") { CONF("font") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
set_first_font(value); set_first_font(value);
} else { } else {
CONF_ERR; CONF_ERR;
} }
} }
}
CONF("xftalpha") { CONF("xftalpha") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value && font_count >= 0) { if (value && font_count >= 0) {
fonts[0].font_alpha = atof(value) * 65535.0; fonts[0].font_alpha = atof(value) * 65535.0;
} else { } else {
CONF_ERR; CONF_ERR;
} }
} }
}
CONF("xftfont") { CONF("xftfont") {
if(x_initialised == NO) X11_initialisation();
if (use_xft) { if (use_xft) {
#else #else
CONF("use_xft") { CONF("use_xft") {
@ -7601,11 +7716,13 @@ static void load_config_file(const char *f)
} }
CONF("font") { CONF("font") {
#endif #endif
if(x_initialised == YES) {
if (value) { if (value) {
set_first_font(value); set_first_font(value);
} else { } else {
CONF_ERR; CONF_ERR;
} }
}
#ifdef XFT #ifdef XFT
} }
#endif #endif
@ -7679,13 +7796,18 @@ static void load_config_file(const char *f)
#ifdef X11 #ifdef X11
#ifdef OWN_WINDOW #ifdef OWN_WINDOW
CONF("own_window") { CONF("own_window") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
own_window = string_to_bool(value); own_window = string_to_bool(value);
} else { } else {
CONF_ERR; CONF_ERR;
} }
} }
}
CONF("own_window_class") { CONF("own_window_class") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
memset(window.class_name, 0, sizeof(window.class_name)); memset(window.class_name, 0, sizeof(window.class_name));
strncpy(window.class_name, value, strncpy(window.class_name, value,
@ -7694,7 +7816,10 @@ static void load_config_file(const char *f)
CONF_ERR; CONF_ERR;
} }
} }
}
CONF("own_window_title") { CONF("own_window_title") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
memset(window.title, 0, sizeof(window.title)); memset(window.title, 0, sizeof(window.title));
strncpy(window.title, value, sizeof(window.title) - 1); strncpy(window.title, value, sizeof(window.title) - 1);
@ -7702,14 +7827,20 @@ static void load_config_file(const char *f)
CONF_ERR; CONF_ERR;
} }
} }
}
CONF("own_window_transparent") { CONF("own_window_transparent") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
set_transparent = string_to_bool(value); set_transparent = string_to_bool(value);
} else { } else {
CONF_ERR; CONF_ERR;
} }
} }
}
CONF("own_window_colour") { CONF("own_window_colour") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
background_colour = get_x11_color(value); background_colour = get_x11_color(value);
} else { } else {
@ -7717,7 +7848,10 @@ static void load_config_file(const char *f)
"'#' for hex colours"); "'#' for hex colours");
} }
} }
}
CONF("own_window_hints") { CONF("own_window_hints") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
char *p_hint, *p_save; char *p_hint, *p_save;
char delim[] = ", "; char delim[] = ", ";
@ -7749,7 +7883,10 @@ static void load_config_file(const char *f)
CONF_ERR; CONF_ERR;
} }
} }
}
CONF("own_window_type") { CONF("own_window_type") {
if(x_initialised == NO) X11_initialisation();
if(x_initialised == YES) {
if (value) { if (value) {
if (strncmp(value, "normal", 6) == EQUAL) { if (strncmp(value, "normal", 6) == EQUAL) {
window.type = TYPE_NORMAL; window.type = TYPE_NORMAL;
@ -7767,6 +7904,7 @@ static void load_config_file(const char *f)
CONF_ERR; CONF_ERR;
} }
} }
}
#endif #endif
CONF("stippled_borders") { CONF("stippled_borders") {
if (value) { if (value) {
@ -8084,11 +8222,6 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
#ifdef X11
/* initalize X BEFORE we load config.
* (we need to so that 'screen' is set) */
init_X11();
#endif /* X11 */
/* check if specified config file is valid */ /* check if specified config file is valid */
if (current_config) { if (current_config) {
@ -8238,7 +8371,7 @@ int main(int argc, char **argv)
#ifdef X11 #ifdef X11
/* load font */ /* load font */
load_fonts(); if ( output_methods & TO_X ) load_fonts();
#endif /* X11 */ #endif /* X11 */
/* generate text and get initial size */ /* generate text and get initial size */
@ -8282,6 +8415,7 @@ int main(int argc, char **argv)
memset(tmpstring2, 0, text_buffer_size); memset(tmpstring2, 0, text_buffer_size);
#ifdef X11 #ifdef X11
if ( output_methods & TO_X ) {
selected_font = 0; selected_font = 0;
update_text_area(); /* to get initial size of the window */ update_text_area(); /* to get initial size of the window */
@ -8311,6 +8445,7 @@ int main(int argc, char **argv)
set_font(); set_font();
draw_stuff(); draw_stuff();
}
#endif /* X11 */ #endif /* X11 */
/* Set signal handlers */ /* Set signal handlers */