From 7a6ce89226586e19195bc7236bc888bd77992394 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Fri, 12 Dec 2008 15:33:25 +0100 Subject: [PATCH] implement sample config printing support This patch makes Conky print a sample config when being called with the '-C' flag. A short test showed an increase of ~10kbytes of the conky binary's size. --- .gitignore | 1 + configure.ac.in | 14 ++++++++++++++ src/Makefile.am | 11 +++++++++++ src/conky.c | 15 +++++++++++++++ 4 files changed, 41 insertions(+) diff --git a/.gitignore b/.gitignore index b9c5f88..2bc946e 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ src/stamp-h1 src/.deps/ src/build.h src/config.h +src/defconfig.h src/*.o conky-*.tar.* doc/*.html diff --git a/configure.ac.in b/configure.ac.in index 6becb80..ee750ed 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -91,6 +91,20 @@ AC_SUBST(BUILD_ARCH) dnl +dnl CONFIG_OUTPUT option +dnl + +AC_ARG_ENABLE([config_output], + AC_HELP_STRING([--enable-config-output], + [enable printing a default config if requested @<:@default=no@:>@]), + [want_config_output="$enableval"], [want_config_output=no]) + +AM_CONDITIONAL(BUILD_CONFIG_OUTPUT, test x$want_config_output = xyes) +if test x$want_config_output = xyes; then + AC_DEFINE(CONFIG_OUTPUT, 1, [Define if you want default config printing support]) +fi + +dnl dnl OWN_WINDOW option dnl diff --git a/src/Makefile.am b/src/Makefile.am index 98a7497..6ee8448 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,6 +27,15 @@ INCLUDES = -DSYSTEM_CONFIG_FILE=\"$(sysconfdir)/conky/conky.conf\" bin_PROGRAMS = conky +if BUILD_CONFIG_OUTPUT +config_output = defconfig.h +conky_DEPENDENCIES = $(config_output) +BUILT_SOURCES = $(config_output) +CLEANFILES = $(config_output) +$(config_output): ../doc/conky.conf + sh ../text2c.sh $< $@ defconfig +endif + if BUILD_AUDACIOUS audacious = audacious.c audacious.h endif @@ -100,6 +109,7 @@ nvidia = nvidia.c nvidia.h endif conky_SOURCES = \ + $(config_output) \ $(audacious) \ $(bmpx) \ common.c \ @@ -135,6 +145,7 @@ conky_LDFLAGS = \ -lm EXTRA_DIST = \ + $(config_output) \ audacious.c \ audacious.h \ bmpx.c \ diff --git a/src/conky.c b/src/conky.c index 3d38823..2957d8f 100644 --- a/src/conky.c +++ b/src/conky.c @@ -60,6 +60,10 @@ #include #endif +#ifdef CONFIG_OUTPUT +#include "defconfig.h" +#endif + #include "build.h" #include "temphelper.h" @@ -9094,6 +9098,9 @@ static const char *getopt_string = "vVqdDt:u:i:hc:" #ifdef HAVE_XDBE "b" #endif +#ifdef CONFIG_OUTPUT + "C" +#endif #endif /* X11 */ ; @@ -9102,6 +9109,9 @@ static const struct option longopts[] = { { "version", 0, NULL, 'V' }, { "debug", 0, NULL, 'D' }, { "config", 1, NULL, 'c' }, +#ifdef CONFIG_OUTPUT + { "print-config", 0, NULL, 'C' }, +#endif { "daemonize", 0, NULL, 'd' }, #ifdef X11 { "alignment", 1, NULL, 'a' }, @@ -9181,6 +9191,11 @@ int main(int argc, char **argv) case 'h': print_help(argv[0]); return 0; +#ifdef CONFIG_OUTPUT + case 'C': + print_defconfig(); + return 0; +#endif #ifdef X11 case 'w': window.window = strtol(optarg, 0, 0); -- 1.7.9.5