From d45100910a7ea681114e6d05b2bfd66210239913 Mon Sep 17 00:00:00 2001 From: Alex Badea Date: Sun, 20 Jun 2010 13:14:34 +0300 Subject: [PATCH] applet: call espeaktime-now.sh instead of espeak directly --- src/applet.c | 7 +++++-- src/espeaktime-now.sh | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/applet.c b/src/applet.c index 9659081..639f8b4 100644 --- a/src/applet.c +++ b/src/applet.c @@ -6,7 +6,7 @@ #include #include -#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)); diff --git a/src/espeaktime-now.sh b/src/espeaktime-now.sh index fe3c90a..503c341 100755 --- a/src/espeaktime-now.sh +++ b/src/espeaktime-now.sh @@ -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 -- 1.7.9.5