applet: call espeaktime-now.sh instead of espeak directly
[espeaktime] / src / applet.c
index 0ca518a..639f8b4 100644 (file)
@@ -1,11 +1,12 @@
 #include <unistd.h>
+#include <errno.h>
 #include <gtk/gtk.h>
 #include <hildon/hildon.h>
 #include <hildon-cp-plugin/hildon-cp-plugin-interface.h>
 #include <gconf/gconf.h>
 #include <gconf/gconf-client.h>
 
-#define ESPEAK_BIN "espeak"
+#define ESPEAKTIME_BIN "espeaktime-now.sh"
 #define GCONF_KEY "/apps/Maemo/espeaktime"
 
 /* TODO: read these from disk */
@@ -126,7 +127,7 @@ static void cfg_free(struct espeaktime_settings *cfg)
        g_free(cfg->text);
 }
 
-static void do_test(struct espeaktime_settings *cfg)
+static void cfg_speak(struct espeaktime_settings *cfg, gboolean test_mode)
 {
        gchar astr[16], pstr[16], sstr[16];
        gchar vstr[64];
@@ -146,6 +147,9 @@ static void do_test(struct espeaktime_settings *cfg)
                (*cfg->effect) ? "+" : "", cfg->effect);
        strftime(text, sizeof(text), cfg->text, tm);
 
+       setenv("EST_TESTMODE", test_mode ? "1" : "0", 1);
+       setenv("EST_IGN_SILENT", cfg->ignore_silent ? "1" : "0", 1);
+
        pid = fork();
        if (pid < 0) {
                perror("fork");
@@ -155,10 +159,11 @@ static void do_test(struct espeaktime_settings *cfg)
                return;
        g_print("execlp: -a '%s' -p '%s' -s '%s' -v '%s' '%s'\n",
                astr, pstr, sstr, vstr, text);
-       res = execlp(ESPEAK_BIN, ESPEAK_BIN,
+       res = execlp(ESPEAKTIME_BIN, ESPEAKTIME_BIN,
                "-a", astr, "-p", pstr, "-s", sstr, "-v", vstr,
                text, NULL);
-       g_print("execlp: %d\n", res);
+       g_print("execlp: %d (%s)\n", res, g_strerror(errno));
+       exit(res);
 }
 
 
@@ -274,7 +279,7 @@ osso_return_t execute(osso_context_t *osso, gpointer data, gboolean user_activat
                switch (result) {
                case 1:
                        g_print("Test button\n");
-                       do_test(&cfg);
+                       cfg_speak(&cfg, TRUE);
                        continue;
                case GTK_RESPONSE_OK:
                        g_print("Save\n");