Compare commits
2 commits
561d3a681d
...
2d3a9c96ce
Author | SHA1 | Date | |
---|---|---|---|
2d3a9c96ce | |||
4d1dac524e |
7 changed files with 41 additions and 17 deletions
27
Makefile
27
Makefile
|
@ -1,7 +1,6 @@
|
|||
.POSIX:
|
||||
.SUFFIXES:
|
||||
|
||||
CC = cc
|
||||
VERSION = 1.0
|
||||
SERVER = zmr
|
||||
CLIENT = zen
|
||||
|
@ -11,24 +10,24 @@ PREFIX ?= /usr/local
|
|||
BINDIR = $(PREFIX)/bin
|
||||
MANDIR = $(PREFIX)/share/man/man1
|
||||
|
||||
# Flags
|
||||
LDFLAGS = $(shell pkg-config --libs libsodium libnotify ncurses sqlite3)
|
||||
CFLAGS = -O3 -mtune=native -march=native -pipe -s -std=c99 -Wno-pointer-sign -pedantic -Wall -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 $(shell pkg-config --cflags libsodium libnotify ncurses sqlite3) -lpthread
|
||||
LDFLAGS != pkg-config --libs libsodium libnotify ncurses sqlite3
|
||||
INCFLAGS != pkg-config --cflags libsodium libnotify ncurses sqlite3
|
||||
CFLAGS = -Os -mtune=native -march=native -pipe -s -std=c99 -Wno-pointer-sign -pedantic -Wall -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 $(INCFLAGS) -lpthread -lluft -L.
|
||||
|
||||
SERVERSRC = src/zmr/*.c
|
||||
CLIENTSRC = src/zen/*.c
|
||||
LIBSRC = src/lib/*.c
|
||||
INCLUDE = -Iinclude/
|
||||
SERVERSRC != find src/zmr -name "*.c"
|
||||
CLIENTSRC != find src/zen -name "*.c"
|
||||
LIBSRC != find src/lib -name "*.c"
|
||||
INCLUDE = include
|
||||
|
||||
all: $(SERVER) $(CLIENT)
|
||||
|
||||
$(SERVER): $(SERVERSRC) $(LIBSRC)
|
||||
mkdir -p bin
|
||||
$(CC) $(SERVERSRC) $(LIBSRC) $(INCLUDE) -o bin/$@ $(CFLAGS) $(LDFLAGS)
|
||||
$(CC) $(SERVERSRC) $(LIBSRC) -I$(INCLUDE) -I. -o bin/$@ $(CFLAGS) $(LDFLAGS)
|
||||
|
||||
$(CLIENT): $(CLIENTSRC) $(LIBSRC)
|
||||
mkdir -p bin
|
||||
$(CC) $(CLIENTSRC) $(LIBSRC) $(INCLUDE) -o bin/$@ $(CFLAGS) $(LDFLAGS)
|
||||
$(CC) $(CLIENTSRC) $(LIBSRC) -I$(INCLUDE) -I. -o bin/$@ $(CFLAGS) $(LDFLAGS)
|
||||
|
||||
dist:
|
||||
mkdir -p $(TARGET)-$(VERSION)
|
||||
|
@ -48,11 +47,11 @@ install: $(TARGET)
|
|||
chmod 644 $(DESTDIR)$(MANDIR)/$(MANPAGE)
|
||||
|
||||
uninstall:
|
||||
$(RM) $(DESTDIR)$(BINDIR)/$(SERVER)
|
||||
$(RM) $(DESTDIR)$(BINDIR)/$(CLIENT)
|
||||
$(RM) $(DESTDIR)$(MANDIR)/$(MANPAGE)
|
||||
rm $(DESTDIR)$(BINDIR)/$(SERVER)
|
||||
rm $(DESTDIR)$(BINDIR)/$(CLIENT)
|
||||
rm $(DESTDIR)$(MANDIR)/$(MANPAGE)
|
||||
|
||||
clean:
|
||||
$(RM) $(SERVER) $(CLIENT)
|
||||
rm $(SERVER) $(CLIENT)
|
||||
|
||||
.PHONY: all dist install uninstall clean
|
||||
|
|
|
@ -4,8 +4,10 @@
|
|||
#define MAX_CLIENTS_PER_THREAD 1024
|
||||
|
||||
/* Client */
|
||||
#define DOMAIN "127.0.0.1"
|
||||
/* #define USERNAME "night" */
|
||||
#define DOMAIN "zsm.night0721.xyz"
|
||||
#define USERNAME "night"
|
||||
|
||||
#define USE_LUFT
|
||||
|
||||
/* UI */
|
||||
#define PANEL_HEIGHT 1
|
||||
|
|
|
@ -2,7 +2,14 @@
|
|||
#define NOTIFICATION_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef USE_LUFT
|
||||
#include "luft.h"
|
||||
#else
|
||||
#include <libnotify/notify.h>
|
||||
#endif
|
||||
|
||||
void send_notification(uint8_t *author, uint8_t *content);
|
||||
|
||||
|
|
6
luft.h
Normal file
6
luft.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef LUFT_H_
|
||||
#define LUFT_H_
|
||||
|
||||
void render_notification(char **texts, int num_of_lines);
|
||||
|
||||
#endif
|
|
@ -1,8 +1,15 @@
|
|||
#include "util.h"
|
||||
#include "zen/notification.h"
|
||||
#include "config.h"
|
||||
|
||||
void send_notification(uint8_t *author, uint8_t *content)
|
||||
{
|
||||
#ifdef USE_LUFT
|
||||
char *texts[3];
|
||||
texts[0] = author;
|
||||
texts[1] = content;
|
||||
render_notification(texts, 2);
|
||||
#else
|
||||
NotifyNotification *notification = notify_notification_new((char *) author,
|
||||
(char *) content, "dialog-information");
|
||||
if (notification == NULL) {
|
||||
|
@ -12,4 +19,5 @@ void send_notification(uint8_t *author, uint8_t *content)
|
|||
write_log(LOG_ERROR, "Cannot show notifcation");
|
||||
}
|
||||
g_object_unref(G_OBJECT(notification));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -142,9 +142,11 @@ int main()
|
|||
}
|
||||
|
||||
/* Init libnotify with app name */
|
||||
#ifndef USE_LUFT
|
||||
if (notify_init("zen") < 0) {
|
||||
error(1, "Error initializing libnotify");
|
||||
}
|
||||
#endif
|
||||
|
||||
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sockfd < 0) {
|
||||
|
|
0
zsm.1
Normal file
0
zsm.1
Normal file
Loading…
Reference in a new issue