diff --git a/Makefile b/Makefile index 5553b3e..a45d198 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ include toggle.mk # spmenu version VERSION = 1.1 -CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XINERAMATOGGLE) $(BDTOGGLE) $(PANGOTOGGLE) $(IMLIB2TOGGLE) $(LIBCONFIGTOGGLE) +CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XINERAMATOGGLE) $(BDTOGGLE) $(PANGOTOGGLE) $(IMLIB2TOGGLE) $(LIBCONFIGTOGGLE) $(XRDBTOGGLE) CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations $(OPT) $(INCS) $(CPPFLAGS) LDFLAGS = $(LIBS) INCS = -I$(X11INC) -I$(FREETYPEINC) -I$(BDINC) `pkg-config --cflags $(XFTCONF) $(PANGOCONF) $(PANGOXFTCONF) $(OPENSSLCONF) $(LIBCONFIGCONF)` diff --git a/build.sh b/build.sh index 525b4cf..e1975ea 100755 --- a/build.sh +++ b/build.sh @@ -7,6 +7,7 @@ makebin="${makebin:-$(command -v make)}" cc="${cc:-${CC:-gcc}}" opt="${opt:-${OPT:--O2}}" warn="${warn:-true}" +xresources="" check_dist() { [ -f "/etc/pacman.conf" ] && [ "$warn" != "false" ] && printf "hint: detected Pacman. if you want you can run 'makepkg' with proper arguments to install it using pacman.\n" && pacman=true @@ -98,6 +99,11 @@ build() { libconfigconf="libconfig" fi + # xresources + if [ "$xresources" = "true" ]; then + xrdbtoggle="-DXRESOURCES" + fi + # fribidi if [ "$fribidi" = "true" ]; then bdlibs="-lfribidi" @@ -131,6 +137,7 @@ build() { OPENSSLCONF="$opensslconf" \ LIBCONFIGTOGGLE="$libconfigtoggle" \ LIBCONFIGCONF="$libconfigconf" \ + XRDBTOGGLE="$xrdbtoggle" \ X11LIB="$X11LIB" \ X11INC="$X11INC" } @@ -160,6 +167,7 @@ install() { OPENSSLCONF="$opensslconf" \ LIBCONFIGTOGGLE="$libconfigtoggle" \ LIBCONFIGCONF="$libconfigconf" \ + XRDBTOGGLE="$xrdbtoggle" \ X11LIB="$X11LIB" \ X11INC="$X11INC" } diff --git a/buildconf b/buildconf index 2308e3f..c0e4508 100755 --- a/buildconf +++ b/buildconf @@ -11,6 +11,7 @@ xinerama=true # enable multi monitor support openssl=true # enable support for openssl, used to calculate MD5 fribidi=true # enable support for right to left languages libconfig=true # enable configuration and themes +xresources=true # enable .Xresources support cc=gcc # compiler and linker opt=-O2 # level of optimization warn=true # warn about OS quirks diff --git a/libs/argv.c b/libs/argv.c index 4dd0984..278ce62 100644 --- a/libs/argv.c +++ b/libs/argv.c @@ -51,8 +51,12 @@ void readargs(int argc, char *argv[]) { // init/read xrdb if (xresources) { + #if USEXRESOURCES XrmInitialize(); load_xresources(); + #else + ; // avoids a warning + #endif } // no arguments diff --git a/libs/xrdb.c b/libs/xrdb.c index 237b05f..c9f78ed 100644 --- a/libs/xrdb.c +++ b/libs/xrdb.c @@ -1,3 +1,4 @@ +#if USEXRESOURCES void resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst) { char *sdst = NULL; int *idst = NULL; @@ -49,3 +50,4 @@ void load_xresources(void) { XCloseDisplay(display); } +#endif diff --git a/libs/xrdb.h b/libs/xrdb.h index 9007c7a..93bb0d6 100644 --- a/libs/xrdb.h +++ b/libs/xrdb.h @@ -1,3 +1,4 @@ +#if USEXRESOURCES enum resource_type { STRING = 0, INTEGER = 1, @@ -13,3 +14,4 @@ typedef struct { // declare functions static void load_xresources(void); static void resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst); +#endif diff --git a/libs/xresources.h b/libs/xresources.h index 4bfc606..a4ca613 100644 --- a/libs/xresources.h +++ b/libs/xresources.h @@ -1,4 +1,5 @@ // This .Xresources array is read and compared to the xrdb. Simply add to the array if you need to. +#if USEXRESOURCES ResourcePref resources[] = { { "font", STRING, &font }, { "col_caretfg", STRING, &col_caretfg }, @@ -207,3 +208,4 @@ ResourcePref cols[] = { { "color14", STRING, &col_sgr14 }, { "color15", STRING, &col_sgr15 }, }; +#endif diff --git a/spmenu.c b/spmenu.c index 4e01f71..2d7aebc 100644 --- a/spmenu.c +++ b/spmenu.c @@ -57,6 +57,13 @@ #define USECONFIG 1 #endif +// check if we should enable .Xresources support +#ifndef XRESOURCES +#define USEXRESOURCES 0 +#else +#define USEXRESOURCES 1 +#endif + // include fribidi used for right to left language support #if USERTL #include @@ -83,9 +90,13 @@ #include #include #include -#include #include +// include xresources +#if USEXRESOURCES +#include +#endif + // include pango used for markup #if USEPANGO #include diff --git a/toggle.mk b/toggle.mk index 5842101..aa14dd3 100644 --- a/toggle.mk +++ b/toggle.mk @@ -29,3 +29,7 @@ OPENSSLCONF = openssl # Comment these lines if you don't need it. LIBCONFIGTOGGLE = -DCONFIG LIBCONFIGCONF = libconfig + +# .Xresources/xrdb support +# Comment this line if you don't need it. +XRDBTOGGLE = -DXRESOURCES