The reason why an event-script fails to send a "growler" message is that mcabber
closes the standard input, output and error streams when it runs an event command. You can see this in hooks.c
:
if ((pid=fork()) == -1) {
scr_LogPrint(LPRINT_LOGNORM, "Fork error, cannot launch external command.");
g_free(datafname);
return;
}
if (pid == 0) { // child
// Close standard file descriptors
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
if (execl(extcmd, extcmd, arg_type, arg_info, bjid, arg_data,
(char *)NULL) == -1) {
// scr_LogPrint(LPRINT_LOGNORM, "Cannot execute external command.");
exit(1);
}
}
g_free(datafname);
That makes the event script run without interfering with the streams used by mcabber
.
There is no special ncurses mode intercepting the message (after all, tmux
is already running as a terminfo application). You can probably work around the problem by redirecting your echo
(preferably printf
) to /dev/tty
, e.g.,
#!/bin/sh
printf '\033Ptmux;\033\033]9;foobar\007\033\\' >/dev/tty
In your script, these assignments
normal='\e[0m'
yellow='\e[33m'
put those characters literally into the variables, i.e., \e[0m, rather than the escape sequence. You can construct an escape character using printf
(or some versions of echo
), e.g.,
normal=$(printf '\033[0m')
yellow=$(printf '\033[33m')
but you would do much better to use tput
, as this will work for any correctly set up terminal:
normal=$(tput sgr0)
yellow=$(tput setaf 3)
Looking at your example, it seems that the version of printf
you are using treats \e
as the escape character (which may work on your system, but is not generally portable to other systems). To see this, try
yellow='\e[33m'
printf 'Yellow:%s\n' $yellow
and you would see the literal characters:
Yellow:\e[33m
rather than the escape sequence. Putting those in the printf
format tells printf
to interpret them (if it can).
Further reading:
Best Answer
Use
-R
flag:From
less
man page.