From 4a41fd428bfd4ed95446e6f24bbd6ec60d87bf50 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Fri, 17 Apr 2020 16:32:09 +0200 Subject: Using libespeak and libnotify --- src/jo_lowbat.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/jo_lowbat.h | 8 +++++++- src/jo_main.c | 37 ------------------------------------- src/jo_main.h | 22 ---------------------- src/jo_n_notify.c | 32 ++++++++++++++++++++++++++++++++ src/jo_n_notify.h | 27 +++++++++++++++++++++++++++ src/jo_n_speak.c | 29 +++++++++++++++++++++++++++++ src/jo_n_speak.h | 21 +++++++++++++++++++++ 8 files changed, 161 insertions(+), 60 deletions(-) create mode 100644 src/jo_lowbat.c delete mode 100644 src/jo_main.c delete mode 100644 src/jo_main.h create mode 100644 src/jo_n_notify.c create mode 100644 src/jo_n_notify.h create mode 100644 src/jo_n_speak.c create mode 100644 src/jo_n_speak.h (limited to 'src') diff --git a/src/jo_lowbat.c b/src/jo_lowbat.c new file mode 100644 index 0000000..da7c575 --- /dev/null +++ b/src/jo_lowbat.c @@ -0,0 +1,45 @@ +/****************************************************************************************/ +/* */ +/* File : jo_lowbat.c /_________/ */ +/* Author : Joe | */ +/* Date : 04/2020 | */ +/* Info : The main | */ +/* / | */ +/* \ / */ +/* \_____/ */ +/* */ +/****************************************************************************************/ + +#include +#include + +/* +** Files prefixes +** -------------- +** f: fetch +** n: notify +*/ + +int +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); + } + if ((percent = jo_f_percent()) == -3) { + return (JO_RET_RD_FAILED); + } + printf("status: %hhd, %hhd%%\n", status, percent); + /* 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 +#include +#include +#include +#include +#include +#include +#include enum { diff --git a/src/jo_main.c b/src/jo_main.c deleted file mode 100644 index a6d05b1..0000000 --- a/src/jo_main.c +++ /dev/null @@ -1,37 +0,0 @@ -/****************************************************************************************/ -/* */ -/* File : jo_main.c /_________/ */ -/* Author : Joe | */ -/* Date : 04/2020 | */ -/* Info : The main | */ -/* / | */ -/* \ / */ -/* \_____/ */ -/* */ -/****************************************************************************************/ - -#include - -/* -** Files prefixes -** -------------- -** f: fetch -** n: notify -*/ - -int -main(void) -{ - int8_t status; - int8_t percent; - - if ((status = jo_f_status()) == -2) { - return (JO_RET_RD_FAILED); - } - if ((percent = jo_f_percent()) == -3) { - return (JO_RET_RD_FAILED); - } - printf("status: %hhd, %hhd%%\n", status, percent); - /* ESPEAK */ - return (JO_RET_FINE); -} diff --git a/src/jo_main.h b/src/jo_main.h deleted file mode 100644 index 742f1d9..0000000 --- a/src/jo_main.h +++ /dev/null @@ -1,22 +0,0 @@ -/****************************************************************************************/ -/* */ -/* File : jo_main.h /_________/ */ -/* Author : Joe | */ -/* Date : 04/2020 | */ -/* | */ -/* / | */ -/* \ / */ -/* \_____/ */ -/* */ -/****************************************************************************************/ - -#ifndef JO_MAIN_H -#define JO_MAIN_H - -#include -#include -#include -#include -#include - -#endif 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 + +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 +#include +#include + +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 + +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_n_speak.h b/src/jo_n_speak.h new file mode 100644 index 0000000..36dced4 --- /dev/null +++ b/src/jo_n_speak.h @@ -0,0 +1,21 @@ +/****************************************************************************************/ +/* */ +/* File : jo_n_speak.h /_________/ */ +/* Author : Joe | */ +/* Date : 04/2020 | */ +/* Info : Use espeak lib to speak | */ +/* / | */ +/* \ / */ +/* \_____/ */ +/* */ +/****************************************************************************************/ + +#ifndef JO_N_SPEAK_H +#define JO_N_SPEAK_H + +#include +#include + +void jo_n_speak(const char *); + +#endif -- cgit v1.2.3