Removed libnotify dependency

This commit is contained in:
Antonio Bibiano 2016-05-03 10:29:46 +10:00
parent cafb6102db
commit d55edcb9b6
3 changed files with 10 additions and 16 deletions

View File

@ -1,7 +1,7 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
/* Notification */ /* Notification */
static char *notifycmd = "libnotify"; /* Use libnotify or given command */ static char *notifycmd = ""; /* Use libnotify or given command */
static char *notifyext = ""; /* Notify with extra command (eg. play an alarm) */ static char *notifyext = ""; /* Notify with extra command (eg. play an alarm) */
/* /*

View File

@ -2,16 +2,16 @@
VERSION = 0.1 VERSION = 0.1
# Customize below to fit your system # Customize below to fit your system
#USE_LIBNOTIFY = -DUSE_LIBNOTIFY
#LIBNOTIFY_CFLAGS = `pkg-config --cflags libnotify`
#LIBNOTIFY_LIBS = `pkg-config --libs libnotify`
# paths # paths
PREFIX = /usr/local PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man MANPREFIX = ${PREFIX}/share/man
# includes and libs # includes and libs
INCS = -I. -I/usr/include \ INCS = -I. -I/usr/include ${USE_LIBNOTIFY} ${LIBNOTIFY_CFLAGS}
`pkg-config --cflags libnotify` LIBS = -L/usr/lib ${LIBNOTIFY_LIBSS}
LIBS = -L/usr/lib \
`pkg-config --libs libnotify`
# flags # flags
CPPFLAGS = -DVERSION=\"${VERSION}\" CPPFLAGS = -DVERSION=\"${VERSION}\"

14
spt.c
View File

@ -6,8 +6,6 @@
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
#include <libnotify/notify.h>
#include "arg.h" #include "arg.h"
char *argv0; char *argv0;
@ -58,13 +56,7 @@ spawn(char *cmd)
void void
notify_send(char *cmt) notify_send(char *cmt)
{ {
if (!strcmp(notifycmd, "libnotify")) { /* use libnotify */ if (strcmp(notifycmd, "")) {
notify_init("spt");
NotifyNotification *n = notify_notification_new("spt", cmt, "dialog-information");
notify_notification_show(n, NULL);
g_object_unref(G_OBJECT(n));
notify_uninit();
} else if (strcmp(notifycmd, "")) {
/* TODO(pickfire): merge this into spawn() */ /* TODO(pickfire): merge this into spawn() */
if (fork() == 0) { if (fork() == 0) {
setsid(); setsid();
@ -73,6 +65,8 @@ notify_send(char *cmt)
perror(" failed"); perror(" failed");
exit(0); exit(0);
} }
} else {
fprintf(stdout,"%s\n",cmt);
} }
if (strcmp(notifyext, "")) /* extra commands to use */ if (strcmp(notifyext, "")) /* extra commands to use */
@ -97,7 +91,7 @@ remaining_time(int sigint)
void void
usage(void) usage(void)
{ {
die("usage: %s [-e notifyext] [-n notifycmd] [-v]\n", argv0); die("usage: %s [-n notifycmd] [-e notifyext] [-v]\n", argv0);
} }
int int