From c08db2aba5f3b3cba2bc5642b6a61216b50fdf59 Mon Sep 17 00:00:00 2001 From: Philip Kovacs Date: Tue, 23 Oct 2007 21:52:11 +0000 Subject: [PATCH] Externalize default config file: /conky/conky.conf git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@981 7f574dfc-610e-0410-a909-a81674777703 --- ChangeLog | 3 ++ Makefile.am | 29 ++++++++++++++++++- autogen.sh | 27 ++++++++++++++++-- configure.ac.in | 2 ++ data/Makefile.am | 30 ++++++++++++++++++++ data/conky.conf | 48 +++++++++++++++++++++++++++++++ src/Makefile.am | 29 +++++++++++++++++++ src/conky.c | 83 ++++++++++++++++++------------------------------------ 8 files changed, 192 insertions(+), 59 deletions(-) create mode 100644 data/Makefile.am create mode 100644 data/conky.conf diff --git a/ChangeLog b/ChangeLog index d9ea0e4..793563f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ # $Id$ +2008-10-23 + * Externalize default config file: ${sysconfdir}/conky/conky.conf + 2008-10-21 * Initialize music_player_interval so built-in .conkyrc actual works. * Lower timed_thread minimum timing interval from 50 usecs to 10 usecs. diff --git a/Makefile.am b/Makefile.am index bd705b1..a9a65fa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,33 @@ +# Conky, a system monitor, based on torsmo +# +# Any original torsmo code is licensed under the BSD license +# +# All code written since the fork of torsmo is licensed under the GPL +# +# Please see COPYING for details +# +# Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen +# Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS) +# All rights reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# $Id$ + SUBDIRS = \ src \ - doc + doc \ + data AUTOMAKE_OPTIONS = \ 1.8 \ diff --git a/autogen.sh b/autogen.sh index 232d919..8ff0c33 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,7 +1,30 @@ #!/bin/sh +# +# Conky, a system monitor, based on torsmo +# +# Any original torsmo code is licensed under the BSD license +# +# All code written since the fork of torsmo is licensed under the GPL +# +# Please see COPYING for details +# +# Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen +# Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS) +# All rights reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# # $Id$ - -# autogen.sh # # optional $1 = optional directory containing build tree or svn working copy diff --git a/configure.ac.in b/configure.ac.in index 8a72238..7c582a1 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -39,6 +39,7 @@ PKG_PROG_PKG_CONFIG([0.19]) AC_CONFIG_FILES( Makefile + data/Makefile doc/Makefile src/Makefile src/build.h @@ -543,6 +544,7 @@ cat << EOF $PACKAGE $VERSION configured successfully: Installing into: $prefix + System config dir: $sysconfdir C compiler flags: $CFLAGS Linker flags: $LDFLAGS Libraries: $LIBS diff --git a/data/Makefile.am b/data/Makefile.am new file mode 100644 index 0000000..1859364 --- /dev/null +++ b/data/Makefile.am @@ -0,0 +1,30 @@ +# Conky, a system monitor, based on torsmo +# +# Any original torsmo code is licensed under the BSD license +# +# All code written since the fork of torsmo is licensed under the GPL +# +# Please see COPYING for details +# +# Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen +# Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS) +# All rights reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# $Id$ + +configdir = ${sysconfdir}/conky +dist_config_DATA = conky.conf + +# vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/data/conky.conf b/data/conky.conf new file mode 100644 index 0000000..7a0032f --- /dev/null +++ b/data/conky.conf @@ -0,0 +1,48 @@ +alignment bottom_left +background no +border_width 1 +cpu_avg_samples 2 +default_color white +default_outline_color white +default_shade_color white +draw_borders no +draw_graph_borders yes +draw_outline no +draw_shades no +font 6x10 +gap_x 5 +gap_y 60 +minimum_size 5 5 +net_avg_samples 2 +no_buffers yes +out_to_console no +own_window yes +own_window_class Conky +own_window_type normal +stippled_borders 0 +update_interval 3.0 +uppercase no +use_spacer no + +TEXT +$nodename - $sysname $kernel on $machine +$hr +${color grey}Uptime:$color $uptime +${color grey}Frequency (in MHz):$color $freq +${color grey}Frequency (in GHz):$color $freq_g +${color grey}RAM Usage:$color $mem/$memmax - $memperc% ${membar 4} +${color grey}Swap Usage:$color $swap/$swapmax - $swapperc% ${swapbar 4} +${color grey}CPU Usage:$color $cpu% ${cpubar 4} +${color grey}Processes:$color $processes ${color grey}Running:$color $running_processes +$hr +${color grey}File systems: + / $color${fs_free /}/${fs_size /} ${fs_bar 6 /} +${color grey}Networking: +Up:$color ${upspeed eth0} k/s${color grey} - Down:$color ${downspeed eth0} k/s +$hr +${color grey}Name PID CPU% MEM% +${color lightgrey} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1} +${color lightgrey} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2} +${color lightgrey} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3} +${color lightgrey} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4} + diff --git a/src/Makefile.am b/src/Makefile.am index 9d98616..7b074ca 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,3 +1,32 @@ +# Conky, a system monitor, based on torsmo +# +# Any original torsmo code is licensed under the BSD license +# +# All code written since the fork of torsmo is licensed under the GPL +# +# Please see COPYING for details +# +# Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen +# Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS) +# All rights reserved. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# $Id$ + +INCLUDES = \ + -DSYSTEM_CONFIG_FILE=\"$(sysconfdir)/conky/conky.conf\" + bin_PROGRAMS = conky if BUILD_AUDACIOUS diff --git a/src/conky.c b/src/conky.c index 9c645f0..dc51c29 100644 --- a/src/conky.c +++ b/src/conky.c @@ -411,39 +411,7 @@ static int pad_percents = 0; tcp_port_monitor_args_t tcp_port_monitor_args; #endif -/* Text that is shown */ -static char original_text[] = - "$nodename - $sysname $kernel on $machine\n" - "$hr\n" - "${color grey}Uptime:$color $uptime\n" - "${color grey}Frequency (in MHz):$color $freq\n" - "${color grey}Frequency (in GHz):$color $freq_g\n" - "${color grey}RAM Usage:$color $mem/$memmax - $memperc% ${membar 4}\n" - "${color grey}Swap Usage:$color $swap/$swapmax - $swapperc% ${swapbar 4}\n" - "${color grey}CPU Usage:$color $cpu% ${cpubar 4}\n" - "${color grey}Processes:$color $processes ${color grey}Running:$color $running_processes\n" - "$hr\n" - "${color grey}File systems:\n" - " / $color${fs_free /}/${fs_size /} ${fs_bar 6 /}\n" - "${color grey}Networking:\n" - " Up:$color ${upspeed eth0} k/s${color grey} - Down:$color ${downspeed eth0} k/s\n" - "$hr\n" -#ifdef MPD - "${color grey}MPD: $mpd_status $mpd_artist - $mpd_title from $mpd_album at $mpd_vol\n" - "Bitrate: $mpd_bitrate\n" "Progress: $mpd_bar\n" -#endif -#ifdef XMMS2 - "${color grey}XMMS2: $xmms2_status $xmms2_artist - $xmms2_title from $xmms2_album\n" - "Progress: $xmms2_bar\n" -#endif - "${color grey}Name PID CPU% MEM%\n" - " ${color lightgrey} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}\n" - " ${color lightgrey} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}\n" - " ${color lightgrey} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}\n" - " ${color lightgrey} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}\n" - ; - -static char *text = original_text; +static char *text = 0; long text_lines; static int total_updates; @@ -6897,7 +6865,7 @@ void clean_up(void) text_object_count = 0; text_objects = NULL; - if (text != original_text) + if (!text) free(text); free(current_config); @@ -7016,7 +6984,7 @@ static void set_default_configurations(void) draw_outline = 0; set_first_font("6x10"); gap_x = 5; - gap_y = 5; + gap_y = 60; minimum_width = 5; minimum_height = 5; maximum_width = 0; @@ -7026,7 +6994,7 @@ static void set_default_configurations(void) window.hints=0; strcpy(window.class_name, "Conky"); update_uname(); - sprintf(window.title,"%s - conky",info.uname_s.nodename); + sprintf(window.title,"Conky (%s)",info.uname_s.nodename); #endif stippled_borders = 0; border_margin = 3; @@ -7568,7 +7536,7 @@ else if (strcasecmp(name, a) == 0 || strcasecmp(name, b) == 0) CONF_ERR; } CONF("text") { - if (text != original_text) + if (!text) free(text); text = (char *) @@ -7694,8 +7662,6 @@ int main(int argc, char **argv) case 'V': print_version(); case 'c': - /* if current_config is set to a strdup of CONFIG_FILE, free it (even - * though free() does the NULL check itself;), then load optarg value */ if (current_config) free(current_config); current_config = strdup(optarg); @@ -7708,9 +7674,7 @@ int main(int argc, char **argv) "window. Command line options will override configurations defined in config\n" "file.\n" " -V version\n" - " -c FILE config file to load instead of " - CONFIG_FILE - "\n" + " -c FILE config file to load\n" " -d daemonize, fork to background\n" " -h help\n" #ifdef X11 @@ -7745,26 +7709,33 @@ int main(int argc, char **argv) init_X11(); #endif /* X11 */ - /* load current_config or CONFIG_FILE */ + /* load current_config, CONFIG_FILE or SYSTEM_CONFIG_FILE */ -#ifdef CONFIG_FILE - if (current_config == NULL) { + if (!current_config) { /* load default config file */ char buf[256]; + FILE *fp; - variable_substitute(CONFIG_FILE, buf, 256); + /* Try to use personal config file first */ + variable_substitute(CONFIG_FILE, buf, sizeof(buf)); + if (buf[0] && (fp=fopen(buf,"r"))) { + current_config = strdup(buf); + fclose(fp); + } - if (buf[0] != '\0') - current_config = strdup(buf); - } -#endif + /* Try to use system config file if personal config not readable */ + if (!current_config && (fp=fopen(SYSTEM_CONFIG_FILE,"r"))) { + current_config = strdup(SYSTEM_CONFIG_FILE); + fclose(fp); + } - if (current_config != NULL && fopen((const char *)current_config, (const char *)"r")) - load_config_file(current_config); - else { - set_default_configurations(); + /* No readable config found */ + if (!current_config) + CRIT_ERR("no readable personal or system-wide config file found"); } + load_config_file(current_config); + /* init specials array */ if ((specials = calloc (sizeof(struct special_t), max_specials)) == 0) ERR("failed to create specials array"); @@ -7825,7 +7796,7 @@ int main(int argc, char **argv) #endif #endif /* X11 */ case 't': - if (text != original_text) + if (!text) free(text); text = strdup(optarg); convert_escapes(text); @@ -7864,7 +7835,7 @@ int main(int argc, char **argv) /* generate text and get initial size */ extract_variable_text(text); - if (text != original_text) { + if (!text) { free(text); } text = NULL; -- 1.7.9.5