diff options
author | Peter Meerwald <pmeerw@pmeerw.net> | 2013-07-29 22:13:41 +0200 |
---|---|---|
committer | David Henningsson <david.henningsson@canonical.com> | 2013-08-02 16:25:27 +0200 |
commit | 193bf997c1f6934bfb79db6c106b656fcdb7a137 (patch) | |
tree | 99b39c11087bd36da66074a6aa0e9f9c1039cd71 | |
parent | e729783331f31a793e21ccf2da21cd9d4388a344 (diff) | |
download | pulseaudio-193bf997c1f6934bfb79db6c106b656fcdb7a137.tar.gz |
pacmd: Discriminate between interactive and non-interactive mode
interactive sessions are initiated with a hello message in order to
receive a welcome message from the PA daemon and a command prompt
interactive sessions have a terminal connected to stdin
non-interactive sessions execute commands given on the command line
or received via stdin; non-interactive sessions have neither welcome
message nor command prompt
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
-rw-r--r-- | src/utils/pacmd.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/utils/pacmd.c b/src/utils/pacmd.c index cf0eb4456..61b87a0ac 100644 --- a/src/utils/pacmd.c +++ b/src/utils/pacmd.c @@ -83,7 +83,7 @@ static void help(const char *argv0) { printf(_("\n" " -h, --help Show this help\n" " --version Show version\n" - "When no command is given pacmd starts in the interactive mode\n" )); + "When no command is given pacmd starts in the interactive mode.\n" )); } enum { @@ -102,7 +102,6 @@ int main(int argc, char*argv[]) { bool ibuf_eof, obuf_eof, ibuf_closed, obuf_closed; struct pollfd pollfd[3]; struct pollfd *watch_socket, *watch_stdin, *watch_stdout; - int stdin_type = 0, stdout_type = 0, fd_type = 0; char *bn = NULL; @@ -209,6 +208,14 @@ int main(int argc, char*argv[]) { ibuf_eof = true; } + if (!ibuf_eof && isatty(STDIN_FILENO)) { + /* send hello to enable interactive mode (welcome message, prompt) */ + if (pa_write(fd, "hello\n", 6, &fd_type) < 0) { + pa_log(_("write(): %s"), strerror(errno)); + goto quit; + } + } + for (;;) { struct pollfd *p; |