1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-15 17:47:09 +00:00

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.
This commit is contained in:
Phil Sutter 2008-12-12 15:33:25 +01:00
parent c84b485178
commit 7a6ce89226
4 changed files with 41 additions and 0 deletions

1
.gitignore vendored
View File

@ -27,6 +27,7 @@ src/stamp-h1
src/.deps/ src/.deps/
src/build.h src/build.h
src/config.h src/config.h
src/defconfig.h
src/*.o src/*.o
conky-*.tar.* conky-*.tar.*
doc/*.html doc/*.html

View File

@ -90,6 +90,20 @@ AC_SUBST(BUILD_DATE)
AC_SUBST(BUILD_ARCH) 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
dnl OWN_WINDOW option dnl OWN_WINDOW option
dnl dnl

View File

@ -27,6 +27,15 @@ INCLUDES = -DSYSTEM_CONFIG_FILE=\"$(sysconfdir)/conky/conky.conf\"
bin_PROGRAMS = conky 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 if BUILD_AUDACIOUS
audacious = audacious.c audacious.h audacious = audacious.c audacious.h
endif endif
@ -100,6 +109,7 @@ nvidia = nvidia.c nvidia.h
endif endif
conky_SOURCES = \ conky_SOURCES = \
$(config_output) \
$(audacious) \ $(audacious) \
$(bmpx) \ $(bmpx) \
common.c \ common.c \
@ -135,6 +145,7 @@ conky_LDFLAGS = \
-lm -lm
EXTRA_DIST = \ EXTRA_DIST = \
$(config_output) \
audacious.c \ audacious.c \
audacious.h \ audacious.h \
bmpx.c \ bmpx.c \

View File

@ -60,6 +60,10 @@
#include <iconv.h> #include <iconv.h>
#endif #endif
#ifdef CONFIG_OUTPUT
#include "defconfig.h"
#endif
#include "build.h" #include "build.h"
#include "temphelper.h" #include "temphelper.h"
@ -9094,6 +9098,9 @@ static const char *getopt_string = "vVqdDt:u:i:hc:"
#ifdef HAVE_XDBE #ifdef HAVE_XDBE
"b" "b"
#endif #endif
#ifdef CONFIG_OUTPUT
"C"
#endif
#endif /* X11 */ #endif /* X11 */
; ;
@ -9102,6 +9109,9 @@ static const struct option longopts[] = {
{ "version", 0, NULL, 'V' }, { "version", 0, NULL, 'V' },
{ "debug", 0, NULL, 'D' }, { "debug", 0, NULL, 'D' },
{ "config", 1, NULL, 'c' }, { "config", 1, NULL, 'c' },
#ifdef CONFIG_OUTPUT
{ "print-config", 0, NULL, 'C' },
#endif
{ "daemonize", 0, NULL, 'd' }, { "daemonize", 0, NULL, 'd' },
#ifdef X11 #ifdef X11
{ "alignment", 1, NULL, 'a' }, { "alignment", 1, NULL, 'a' },
@ -9181,6 +9191,11 @@ int main(int argc, char **argv)
case 'h': case 'h':
print_help(argv[0]); print_help(argv[0]);
return 0; return 0;
#ifdef CONFIG_OUTPUT
case 'C':
print_defconfig();
return 0;
#endif
#ifdef X11 #ifdef X11
case 'w': case 'w':
window.window = strtol(optarg, 0, 0); window.window = strtol(optarg, 0, 0);