applet: call espeaktime-now.sh instead of espeak directly
authorAlex Badea <vamposdecampos@gmail.com>
Sun, 20 Jun 2010 10:14:34 +0000 (13:14 +0300)
committerAlex Badea <vamposdecampos@gmail.com>
Sun, 20 Jun 2010 10:14:34 +0000 (13:14 +0300)
src/applet.c
src/espeaktime-now.sh

index 9659081..639f8b4 100644 (file)
@@ -6,7 +6,7 @@
 #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 */
@@ -147,6 +147,9 @@ static void cfg_speak(struct espeaktime_settings *cfg, gboolean test_mode)
                (*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");
@@ -156,7 +159,7 @@ static void cfg_speak(struct espeaktime_settings *cfg, gboolean test_mode)
                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 (%s)\n", res, g_strerror(errno));
index fe3c90a..503c341 100755 (executable)
@@ -1,9 +1,16 @@
 #!/bin/sh
 
-fname=/tmp/espeaktime-$$.wav
-espeak -w $fname $(date "+%H:%M")
+# if we ever get empty or bogus arguments, espeak will try to
+# read text from stdin, and hang -- prevent that.
+exec < /dev/null
 
-export PULSE_PROP="module-stream-restore.id=x-maemo-applet-profiles event.id=ringtone-preview"
-nice -n -5 play-sound $fname
+if [ "$EST_IGN_SILENT" = "1" ]; then
+       fname=/tmp/espeaktime-$$.wav
 
-rm -f $fname
+       export PULSE_PROP="module-stream-restore.id=x-maemo-applet-profiles event.id=ringtone-preview"
+       espeak -w $fname "${@}"
+       play-sound $fname
+       rm -f $fname
+else
+       exec espeak "${@}"
+fi