aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile82
-rw-r--r--src/jo_lowbat.c (renamed from src/jo_main.c)16
-rw-r--r--src/jo_lowbat.h8
-rw-r--r--src/jo_n_notify.c32
-rw-r--r--src/jo_n_notify.h27
-rw-r--r--src/jo_n_speak.c29
-rw-r--r--src/jo_n_speak.h (renamed from src/jo_main.h)17
7 files changed, 164 insertions, 47 deletions
diff --git a/Makefile b/Makefile
index bc3350e..9c092ba 100644
--- a/Makefile
+++ b/Makefile
@@ -11,70 +11,86 @@
##########################################################################################
default: all
-
-SHELL := /bin/sh
-# ============================================ DIRS ============================================== #
+# ====================================== DIRS ========================================== #
C_SRCS_DIR = src
A_SRCS_DIR = asm
-# =========================================== FILES ============================================== #
-C_SRCS = ${C_SRCS_DIR}/jo_main.c
-# ------------------------------------------------------------------------------------------------ #
+# ====================================== FILES ========================================= #
+C_SRCS = ${C_SRCS_DIR}/jo_lowbat.c
+C_SRCS += ${C_SRCS_DIR}/jo_n_speak.c
+C_SRCS += ${C_SRCS_DIR}/jo_n_notify.c
+# -------------------------------------------------------------------------------------- #
C_OBJS = ${C_SRCS:.c=.o}
-# ------------------------------------------------------------------------------------------------ #
+# -------------------------------------------------------------------------------------- #
A_SRCS = ${A_SRCS_DIR}/jo_f_status.asm
A_SRCS += ${A_SRCS_DIR}/jo_f_percent.asm
-# ------------------------------------------------------------------------------------------------ #
+# -------------------------------------------------------------------------------------- #
A_OBJS = ${A_SRCS:.asm=.o}
-# ========================================== COMPILER ============================================ #
+# ===================================== COMPILER ======================================= #
CC = clang
-# ------------------------------------------------------------------------------------------------ #
-CFLAGS = -std=c89
+# -------------------------------------------------------------------------------------- #
+CFLAGS = -std=c89
CFLAGS += -Wall
CFLAGS += -Wextra
+CFLAGS += -Wno-comment
+CFLAGS += -Wno-long-long
+CFLAGS += -Wno-c99-extensions
+CFLAGS += -Wno-variadic-macros
CFLAGS += -Werror
CFLAGS += -pedantic
CFLAGS += ${DEBUG}
+# -------------------------------------------------------------------------------------- #
# CFLAGS += ${OPTI}
-# ------------------------------------------------------------------------------------------------ #
+# -------------------------------------------------------------------------------------- #
OPTI = -O2 -pipe
-DEBUG = -glldb
-# ------------------------------------------------------------------------------------------------ #
-LINK = -lc
-# ------------------------------------------------------------------------------------------------ #
+# -------------------------------------------------------------------------------------- #
+DEBUG = -glldb
+# DEBUG += -fsanitize=address
+# -------------------------------------------------------------------------------------- #
+CINCS = -Isrc/
+CINCS += -I/usr/local/include
+CINCS += -I/usr/local/include/glib-2.0
+CINCS += -I/usr/local/lib/glib-2.0/include
+CINCS += -I/usr/local/include/gdk-pixbuf-2.0
+# -------------------------------------------------------------------------------------- #
+LINK = -L/usr/local/lib
+LINK += -lnotify
+LINK += -lespeak
+LINK += -lc
+# -------------------------------------------------------------------------------------- #
TARGET = lowbat
-# ========================================== ASSEMBLER =========================================== #
+# ===================================== ASSEMBLER ====================================== #
ASM = nasm
ASMFLAGS = -g -f
ASMARCH = elf64
-# ============================================ UNIX ============================================== #
+# ======================================= UNIX ========================================= #
+SHELL := /bin/sh
RM = rm -f
MKDIR = mkdir -p
CP = cp
MV = mv
SED = sed
-# ============================================ RULES ============================================= #
-
+# ======================================= RULES ======================================== #
.SUFFIXES: .asm .c .o
-
+.PHONY: all clean fclean re depend
+# -------------------------------------------------------------------------------------- #
.asm.o:
${ASM} ${ASMFLAGS} ${ASMARCH} -o ${.TARGET} ${.IMPSRC}
-
+# -------------------------------------------------------------------------------------- #
.c.o:
- ${CC} -c ${CFLAGS} -I${C_SRCS_DIR} -o ${.TARGET} ${.IMPSRC}
-
+ ${CC} -c ${CFLAGS} ${CINCS} -o ${.TARGET} ${.IMPSRC}
+# -------------------------------------------------------------------------------------- #
${TARGET}: ${A_OBJS} ${C_OBJS}
- ${CC} ${CFLAGS} -I${C_SRCS_DIR} -o ${.TARGET} ${.ALLSRC} ${LINK}
-
+ ${CC} ${CFLAGS} ${CINCS} -o ${.TARGET} ${.ALLSRC} ${LINK}
+# -------------------------------------------------------------------------------------- #
depend:
- ${CC} -I${C_SRCS_DIR} -E -MM ${C_SRCS} > .depend
+ ${CC} ${CINCS} -E -MM ${C_SRCS} > .depend
${SED} 's/^/${C_SRCS_DIR}\//' .depend > .depend.tmp
${MV} .depend.tmp .depend
-
+# -------------------------------------------------------------------------------------- #
all: depend ${TARGET}
-
+# -------------------------------------------------------------------------------------- #
clean:
${RM} ${C_OBJS} ${A_OBJS} ${TARGET}.core .depend .depend.tmp ${TARGET}
-
-re: fclean all
-
-.PHONY: all clean fclean re depend
+# -------------------------------------------------------------------------------------- #
+re: clean all
+# ======================================== EOF ========================================= #
diff --git a/src/jo_main.c b/src/jo_lowbat.c
index a6d05b1..da7c575 100644
--- a/src/jo_main.c
+++ b/src/jo_lowbat.c
@@ -1,6 +1,6 @@
/****************************************************************************************/
/* */
-/* File : jo_main.c /_________/ */
+/* File : jo_lowbat.c /_________/ */
/* Author : Joe | */
/* Date : 04/2020 | */
/* Info : The main | */
@@ -10,7 +10,8 @@
/* */
/****************************************************************************************/
-#include <jo_main.h>
+#include <jo_lowbat.h>
+#include <libnotify/notify.h>
/*
** Files prefixes
@@ -20,11 +21,16 @@
*/
int
-main(void)
+main(
+ int argc,
+ const char *argv[]
+ )
{
int8_t status;
int8_t percent;
+ (void)argc;
+ (void)argv;
if ((status = jo_f_status()) == -2) {
return (JO_RET_RD_FAILED);
}
@@ -32,6 +38,8 @@ main(void)
return (JO_RET_RD_FAILED);
}
printf("status: %hhd, %hhd%%\n", status, percent);
- /* ESPEAK */
+ /* NOTIFY-SEND */
+ jo_n_notify("VEGA: Yo", "Welcome", NOTIFY_URGENCY_LOW, 5000);
+ jo_n_speak("Heya!");
return (JO_RET_FINE);
}
diff --git a/src/jo_lowbat.h b/src/jo_lowbat.h
index 9a3b9e3..9e1fa7f 100644
--- a/src/jo_lowbat.h
+++ b/src/jo_lowbat.h
@@ -13,7 +13,13 @@
#ifndef JO_LOWBAT_H
#define JO_LOWBAT_H
-#include <inttypes.h>
+#include <jo_lowbat.h>
+#include <jo_n_speak.h>
+#include <jo_n_notify.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+#include <stdint.h>
enum
{
diff --git a/src/jo_n_notify.c b/src/jo_n_notify.c
new file mode 100644
index 0000000..7abb827
--- /dev/null
+++ b/src/jo_n_notify.c
@@ -0,0 +1,32 @@
+/****************************************************************************************/
+/* */
+/* File : jo_n_notify.c /_________/ */
+/* Author : Joe | */
+/* Date : 04/2020 | */
+/* Info : Uses libnotify lib to notify | */
+/* / | */
+/* \ / */
+/* \_____/ */
+/* */
+/****************************************************************************************/
+
+#include <jo_n_notify.h>
+
+void
+jo_n_notify(
+ const char head[],
+ const char body[],
+ NotifyUrgency u,
+ int32_t t
+ )
+{
+ NotifyNotification *n;
+
+ notify_init("lowbat");
+ n = notify_notification_new(head, body, NULL);
+ notify_notification_set_urgency(n, u);
+ notify_notification_set_timeout(n, t);
+ notify_notification_show(n, NULL);
+ notify_uninit();
+ n = NULL;
+}
diff --git a/src/jo_n_notify.h b/src/jo_n_notify.h
new file mode 100644
index 0000000..7011baa
--- /dev/null
+++ b/src/jo_n_notify.h
@@ -0,0 +1,27 @@
+/****************************************************************************************/
+/* */
+/* File : jo_n_notify.h /_________/ */
+/* Author : Joe | */
+/* Date : 04/2020 | */
+/* Info : Uses libnotify lib to notify | */
+/* / | */
+/* \ / */
+/* \_____/ */
+/* */
+/****************************************************************************************/
+
+#ifndef JO_N_NOTIFY_H
+#define JO_N_NOTIFY_H
+
+#include <libnotify/notify.h>
+#include <stddef.h>
+#include <stdint.h>
+
+void jo_n_notify(
+ const char[],
+ const char[],
+ NotifyUrgency,
+ int32_t
+ );
+
+#endif
diff --git a/src/jo_n_speak.c b/src/jo_n_speak.c
new file mode 100644
index 0000000..4db4113
--- /dev/null
+++ b/src/jo_n_speak.c
@@ -0,0 +1,29 @@
+/****************************************************************************************/
+/* */
+/* File : jo_n_speak.c /_________/ */
+/* Author : Joe | */
+/* Date : 04/2020 | */
+/* Info : Uses espeak lib to speak | */
+/* / | */
+/* \ / */
+/* \_____/ */
+/* */
+/****************************************************************************************/
+
+#include <jo_n_speak.h>
+
+void
+jo_n_speak(const char *msg)
+{
+ espeak_Initialize(AUDIO_OUTPUT_PLAYBACK, 0, 0x0, 0);
+ espeak_Synth(msg,
+ strlen(msg),
+ 0,
+ POS_CHARACTER,
+ 0,
+ espeakCHARS_UTF8 | espeakENDPAUSE,
+ 0x0,
+ 0x0);
+ espeak_Synchronize();
+ espeak_Terminate();
+}
diff --git a/src/jo_main.h b/src/jo_n_speak.h
index 742f1d9..36dced4 100644
--- a/src/jo_main.h
+++ b/src/jo_n_speak.h
@@ -1,22 +1,21 @@
/****************************************************************************************/
/* */
-/* File : jo_main.h /_________/ */
+/* File : jo_n_speak.h /_________/ */
/* Author : Joe | */
/* Date : 04/2020 | */
-/* | */
+/* Info : Use espeak lib to speak | */
/* / | */
/* \ / */
/* \_____/ */
/* */
/****************************************************************************************/
-#ifndef JO_MAIN_H
-#define JO_MAIN_H
+#ifndef JO_N_SPEAK_H
+#define JO_N_SPEAK_H
-#include <jo_lowbat.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <inttypes.h>
+#include <espeak/speak_lib.h>
+#include <string.h>
+
+void jo_n_speak(const char *);
#endif