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:
|
.POSIX:
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
|
|
||||||
CC = cc
|
|
||||||
VERSION = 1.0
|
VERSION = 1.0
|
||||||
SERVER = zmr
|
SERVER = zmr
|
||||||
CLIENT = zen
|
CLIENT = zen
|
||||||
|
@ -11,24 +10,24 @@ PREFIX ?= /usr/local
|
||||||
BINDIR = $(PREFIX)/bin
|
BINDIR = $(PREFIX)/bin
|
||||||
MANDIR = $(PREFIX)/share/man/man1
|
MANDIR = $(PREFIX)/share/man/man1
|
||||||
|
|
||||||
# Flags
|
LDFLAGS != pkg-config --libs libsodium libnotify ncurses sqlite3
|
||||||
LDFLAGS = $(shell pkg-config --libs libsodium libnotify ncurses sqlite3)
|
INCFLAGS != pkg-config --cflags 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
|
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
|
SERVERSRC != find src/zmr -name "*.c"
|
||||||
CLIENTSRC = src/zen/*.c
|
CLIENTSRC != find src/zen -name "*.c"
|
||||||
LIBSRC = src/lib/*.c
|
LIBSRC != find src/lib -name "*.c"
|
||||||
INCLUDE = -Iinclude/
|
INCLUDE = include
|
||||||
|
|
||||||
all: $(SERVER) $(CLIENT)
|
all: $(SERVER) $(CLIENT)
|
||||||
|
|
||||||
$(SERVER): $(SERVERSRC) $(LIBSRC)
|
$(SERVER): $(SERVERSRC) $(LIBSRC)
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
$(CC) $(SERVERSRC) $(LIBSRC) $(INCLUDE) -o bin/$@ $(CFLAGS) $(LDFLAGS)
|
$(CC) $(SERVERSRC) $(LIBSRC) -I$(INCLUDE) -I. -o bin/$@ $(CFLAGS) $(LDFLAGS)
|
||||||
|
|
||||||
$(CLIENT): $(CLIENTSRC) $(LIBSRC)
|
$(CLIENT): $(CLIENTSRC) $(LIBSRC)
|
||||||
mkdir -p bin
|
mkdir -p bin
|
||||||
$(CC) $(CLIENTSRC) $(LIBSRC) $(INCLUDE) -o bin/$@ $(CFLAGS) $(LDFLAGS)
|
$(CC) $(CLIENTSRC) $(LIBSRC) -I$(INCLUDE) -I. -o bin/$@ $(CFLAGS) $(LDFLAGS)
|
||||||
|
|
||||||
dist:
|
dist:
|
||||||
mkdir -p $(TARGET)-$(VERSION)
|
mkdir -p $(TARGET)-$(VERSION)
|
||||||
|
@ -48,11 +47,11 @@ install: $(TARGET)
|
||||||
chmod 644 $(DESTDIR)$(MANDIR)/$(MANPAGE)
|
chmod 644 $(DESTDIR)$(MANDIR)/$(MANPAGE)
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
$(RM) $(DESTDIR)$(BINDIR)/$(SERVER)
|
rm $(DESTDIR)$(BINDIR)/$(SERVER)
|
||||||
$(RM) $(DESTDIR)$(BINDIR)/$(CLIENT)
|
rm $(DESTDIR)$(BINDIR)/$(CLIENT)
|
||||||
$(RM) $(DESTDIR)$(MANDIR)/$(MANPAGE)
|
rm $(DESTDIR)$(MANDIR)/$(MANPAGE)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(SERVER) $(CLIENT)
|
rm $(SERVER) $(CLIENT)
|
||||||
|
|
||||||
.PHONY: all dist install uninstall clean
|
.PHONY: all dist install uninstall clean
|
||||||
|
|
|
@ -4,8 +4,10 @@
|
||||||
#define MAX_CLIENTS_PER_THREAD 1024
|
#define MAX_CLIENTS_PER_THREAD 1024
|
||||||
|
|
||||||
/* Client */
|
/* Client */
|
||||||
#define DOMAIN "127.0.0.1"
|
#define DOMAIN "zsm.night0721.xyz"
|
||||||
/* #define USERNAME "night" */
|
#define USERNAME "night"
|
||||||
|
|
||||||
|
#define USE_LUFT
|
||||||
|
|
||||||
/* UI */
|
/* UI */
|
||||||
#define PANEL_HEIGHT 1
|
#define PANEL_HEIGHT 1
|
||||||
|
|
|
@ -2,7 +2,14 @@
|
||||||
#define NOTIFICATION_H
|
#define NOTIFICATION_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifdef USE_LUFT
|
||||||
|
#include "luft.h"
|
||||||
|
#else
|
||||||
#include <libnotify/notify.h>
|
#include <libnotify/notify.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
void send_notification(uint8_t *author, uint8_t *content);
|
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 "util.h"
|
||||||
#include "zen/notification.h"
|
#include "zen/notification.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
void send_notification(uint8_t *author, uint8_t *content)
|
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,
|
NotifyNotification *notification = notify_notification_new((char *) author,
|
||||||
(char *) content, "dialog-information");
|
(char *) content, "dialog-information");
|
||||||
if (notification == NULL) {
|
if (notification == NULL) {
|
||||||
|
@ -12,4 +19,5 @@ void send_notification(uint8_t *author, uint8_t *content)
|
||||||
write_log(LOG_ERROR, "Cannot show notifcation");
|
write_log(LOG_ERROR, "Cannot show notifcation");
|
||||||
}
|
}
|
||||||
g_object_unref(G_OBJECT(notification));
|
g_object_unref(G_OBJECT(notification));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,9 +142,11 @@ int main()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Init libnotify with app name */
|
/* Init libnotify with app name */
|
||||||
|
#ifndef USE_LUFT
|
||||||
if (notify_init("zen") < 0) {
|
if (notify_init("zen") < 0) {
|
||||||
error(1, "Error initializing libnotify");
|
error(1, "Error initializing libnotify");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if (sockfd < 0) {
|
if (sockfd < 0) {
|
||||||
|
|
0
zsm.1
Normal file
0
zsm.1
Normal file
Loading…
Reference in a new issue