Skip to content
Browse files

add command line option to change the pid path

This adds a -P or --pid-path option to the command line which
allows the user to change the path and the name of the pid file created
when espeakup is running as a daemon.

I would like to thank Chris Brannon for the original idea for this.
  • Loading branch information...
1 parent 49dcacb commit 3353241a79f0e2b130dce5e98d656284a7da84f8 @williamh committed May 5, 2011
Showing with 18 additions and 2 deletions.
  1. +11 −1 cli.c
  2. +6 −0 espeakup.8
  3. +1 −1 espeakup.c
View
12 cli.c
@@ -24,12 +24,16 @@
#include "espeakup.h"
+/* pid path */
+extern char *pidPath;
+
/* default voice */
extern char *defaultVoice;
/* command line options */
-const char *shortOptions = "dhV:v";
+const char *shortOptions = "P:V:dhv";
const struct option longOptions[] = {
+ {"pid-path", required_argument, NULL, 'P'},
{"default-voice", required_argument, NULL, 'V'},
{"debug", no_argument, NULL, 'd'},
{"help", no_argument, NULL, 'h'},
@@ -61,10 +65,16 @@ static void show_version(void)
void process_cli(int argc, char **argv)
{
int opt;
+ char *cp;
do {
opt = getopt_long(argc, argv, shortOptions, longOptions, NULL);
switch (opt) {
+ case 'p':
+ cp = strdup(optarg);
+ if (cp != NULL)
+ pidPath = cp;
+ break;
case 'V':
defaultVoice = strdup(optarg);
break;
View
6 espeakup.8
@@ -9,6 +9,9 @@ espeakup \(em connect Speakup to the ESpeak TTS engine
.SH SYNOPSIS
.B espeakup
[
+.B \-\^\-pid-path=path
+]
+[
.B \-\^\-default-voice=voicename
]
[
@@ -22,6 +25,9 @@ espeakup \(em connect Speakup to the ESpeak TTS engine
]
.SH OPTIONS
.TP
+.B \-P path, \-\^\-pid-path=path
+Set the full path for the pid file espeakup uses when in daemon mode.
+.TP
.B \-V voicename, \-\^\-default-voice=voicename
Set the espeak voice to be used by default.
.TP
View
2 espeakup.c
@@ -27,7 +27,7 @@
#include "espeakup.h"
/* path to our pid file */
-const char *pidPath = "/var/run/espeakup.pid";
+char *pidPath = "/var/run/espeakup.pid";
int debug = 0;
struct queue_t *synth_queue = NULL;

0 comments on commit 3353241

Please sign in to comment.
Something went wrong with that request. Please try again.