aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJozanLeClerc <bousset.rudy@gmail.com>2020-04-17 16:32:09 +0200
committerJozanLeClerc <bousset.rudy@gmail.com>2020-04-17 16:32:09 +0200
commit4a41fd428bfd4ed95446e6f24bbd6ec60d87bf50 (patch)
treec7c5a4ba58b7463659f6660fa56b76fc72fd57a6 /src
parentespeak tests (diff)
downloadlowbat-bsd-4a41fd428bfd4ed95446e6f24bbd6ec60d87bf50.tar.gz
lowbat-bsd-4a41fd428bfd4ed95446e6f24bbd6ec60d87bf50.tar.bz2
lowbat-bsd-4a41fd428bfd4ed95446e6f24bbd6ec60d87bf50.tar.xz
lowbat-bsd-4a41fd428bfd4ed95446e6f24bbd6ec60d87bf50.tar.zst
lowbat-bsd-4a41fd428bfd4ed95446e6f24bbd6ec60d87bf50.zip
Using libespeak and libnotify
Diffstat (limited to 'src')
-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
6 files changed, 115 insertions, 14 deletions
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