diff --git a/config.def.h b/config.def.h index 89f722f..fdc4417 100644 --- a/config.def.h +++ b/config.def.h @@ -1,7 +1,7 @@ /* See LICENSE file for copyright and license details. */ -/* Notification */ -static char *notifycmd = "libnotify"; /* Use libnotify or given command */ +/* Notification, replace libnotify if you don't want it */ +static char *notifycmd = "libnotify"; /* Use libnotify or command given*/ static char *notifyext = ""; /* Notify with extra command (eg. play an alarm) */ /* diff --git a/config.mk b/config.mk index 88b1134..cabd5da 100644 --- a/config.mk +++ b/config.mk @@ -7,15 +7,14 @@ VERSION = 0.1 PREFIX = /usr/local MANPREFIX = ${PREFIX}/share/man -# includes and libs -INCS = -I. -I/usr/include \ - `pkg-config --cflags libnotify` -LIBS = -L/usr/lib \ - `pkg-config --libs libnotify` +# libnotify - comment if you don't want it (config.h too) +INCS = -I. -I/usr/include `pkg-config --cflags libnotify` +LIBS = -L/usr/lib `pkg-config --libs libnotify` +DEFS = -DNOTIFY # flags CPPFLAGS = -DVERSION=\"${VERSION}\" -CFLAGS += -g -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS} +CFLAGS += -g -std=c99 -pedantic -Wall -Os ${INCS} ${DEFS} ${CPPFLAGS} LDFLAGS += -g ${LIBS} # compiler and linker diff --git a/spt.c b/spt.c index 9143ec1..c6c2e7a 100644 --- a/spt.c +++ b/spt.c @@ -5,8 +5,9 @@ #include #include #include - +#ifdef NOTIFY #include +#endif /* NOTIFY */ #include "arg.h" @@ -59,20 +60,21 @@ void notify_send(char *cmt) { if (!strcmp(notifycmd, "libnotify")) { /* use libnotify */ +#ifdef NOTIFY notify_init("spt"); - NotifyNotification *n = notify_notification_new("spt", cmt, "dialog-information"); + NotifyNotification *n = notify_notification_new("spt", cmt, \ + "dialog-information"); notify_notification_show(n, NULL); g_object_unref(G_OBJECT(n)); notify_uninit(); +#endif /* NOTIFY */ } else if (strcmp(notifycmd, "")) { /* TODO(pickfire): merge this into spawn() */ - if (fork() == 0) { setsid(); execlp(notifycmd, "spt", cmt, NULL); fprintf(stderr, "spt: execlp %s", notifycmd); perror(" failed"); exit(0); - } } if (strcmp(notifyext, "")) /* extra commands to use */ @@ -123,7 +125,9 @@ main(int argc, char *argv[]) } run: - notify_send(timers[i].cmt); + if (fork() == 0) { + notify_send(timers[i].cmt); + } for (timecount = 0; timecount < timers[i].tmr; timecount++) { sleep(1);